标签:driver ide ddl drive pid sel 使用 抓取 直接
from selenium import webdriver
from scrapy.http.response.html import HtmlResponse
class JianShuDownloaderMiddleware:
def __init__(self):
self.driver = webdriver.Chrome()
def process_request(self, request, spider):
self.driver.get(request.url)
response = HtmlResponse(
url=self.driver.current_url,
body=self.driver.page_source,
encoding='utf-8',
)
return response
process_request
返回的是一个response对象,那么它会直接将该response返回custom_settings
来进行开启标签:driver ide ddl drive pid sel 使用 抓取 直接
原文地址:https://www.cnblogs.com/ivy-blogs/p/12492443.html