Skip to main content
 首页 » 编程设计

python之如何在已由 scrapy 下载的网页上使用 selenium.PhantomJS()

2025年05月04日14www_RR

def parseList(self, response): 
    dr=webdriver.PhantomJS()    
    dr.get(response.url) 
    pageSource = dr.page_source 
    print dr.page_source 

网页已经被scrapy下载(包含在response.body中),dr.get(response.url)会再次下载。

有没有办法让selenium直接使用response.body?

请您参考如下方法:

如何保存包含 response.body 内容的 HTML 文件,然后做类似的事情

url = "file:///your/path/to/downloaded/file.html" 
dr.get(url)