Giter Site home page Giter Site logo

Comments (4)

elacuesta avatar elacuesta commented on May 22, 2024

Please, share what you have tried.

from scrapy-playwright.

elacuesta avatar elacuesta commented on May 22, 2024

Without more context, all I'll venture to say is that PageCoroutine("fill", "#to_date", "2021-12-17") should produce the expected results.

from scrapy-playwright.

Alfin72 avatar Alfin72 commented on May 22, 2024

sorry for disturbing you during the holiday season.

I am basically trying to log in using playwright and then send the response to scrapy.

Here is how my spider looks.

`import scrapy
from scrapy_playwright.page import PageCoroutine

class ScrollSpider(scrapy.Spider):
name = "quotes"

def start_requests(self):
    yield scrapy.Request(
        url="https://quotes.toscrape.com/login",
        meta=dict(
            playwright=True,
            playwright_include_page=True,
            playwright_context="new",
            playwright_page_coroutines=[
                PageCoroutine("fill", "#username", "2021-12-17"),
                PageCoroutine("fill", "#password", "2021-12-18"),
                PageCoroutine("click", selector="[type='submit']"),
                PageCoroutine("wait_for_timeout", 5000),
            ],
        ),
    )

def parse(self, response):
    # 'response' contains the page as seen by the browser
    yield {"url": response.url}  

Instead of login and returning "https://quotes.toscrape.com/"
I am getting {'url': 'https://quotes.toscrape.com/login'}

Here is the playwright code which I am trying to replicate using scrapy_playwright.

`from playwright.sync_api import sync_playwright

with sync_playwright() as p:
for browser_type in [p.chromium]:
browser = browser_type.launch(headless=False)
page = browser.new_page()
page.goto("https://quotes.toscrape.com/login")
page.fill('#username', '2021-12-16')
page.fill('#password', '2021-12-17')
page.wait_for_timeout(5000)
page.query_selector('[type="submit"]').click()
page.wait_for_timeout(15000)
browser.close()`

from scrapy-playwright.

Alfin72 avatar Alfin72 commented on May 22, 2024

I tried the same code on a different website and the code works, I believe the bug might be in (https://quotes.toscrape.com/login) hence I will close this issue.

from scrapy-playwright.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.