27 lines
No EOL
824 B
Python
27 lines
No EOL
824 B
Python
import scrapy
|
|
|
|
|
|
class QuotesPlaywrightSpider(scrapy.Spider):
|
|
name = "quotes-playwright"
|
|
custom_settings = {
|
|
"DOWNLOAD_HANDLERS": {
|
|
"http": "scrapy_playwright.handler.ScrapyPlaywrightDownloadHandler",
|
|
"https": "scrapy_playwright.handler.ScrapyPlaywrightDownloadHandler",
|
|
},
|
|
"TWISTED_REACTOR": "twisted.internet.asyncioreactor.AsyncioSelectorReactor",
|
|
"PLAYWRIGHT_LAUNCH_OPTIONS": {
|
|
"headless": True,
|
|
}
|
|
}
|
|
|
|
def start_requests(self):
|
|
yield scrapy.Request(
|
|
url="http://quotes.toscrape.com/js/",
|
|
meta={
|
|
"playwright": False,
|
|
},
|
|
)
|
|
|
|
async def parse(self, response):
|
|
with open("playwright-disabled.html", "w") as content:
|
|
content.write(response.text) |