Zyte Api actions searchKeyword

Posted over 1 year ago by scrapers scrapers

Post a topic
Un Answered
s
scrapers scrapers

Hola i am using the zyte api in the documentation, I see that there is the searchKeyword action, I am trying to implement it in a Scrapy project where I need to use the search engine of the target page, but I don't see that it returns me a result beyond the main page what can I be doing wrong ?    

    def start_requests(self):
        yield scrapy.Request(
            'https://example.com',
            meta={
                "zyte_api_automap": {
                    "browserHtml": True,
                    "actions": [
                        {
                            "action": "searchKeyword",
                            "keyword":"product"
                        },
                        {
                            "action": "waitForNavigation",
                            "timeout":31
                        },
                    ],
                    "screenshot": True,
                },
            },
        )

    def parse(self, response):
       
        screenshot_bytes = b64decode(response.raw_api_response["screenshot"])
        print(screenshot_bytes,"\n")
        with open("screenshot.png", "wb") as file:
            file.write(screenshot_bytes)

  

0 Votes


0 Comments

Login to post a comment