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
?
答案 0 :(得分:1)
如何使用response.body
中的内容保存HTML文件,而不是像
url = "file:///your/path/to/downloaded/file.html"
dr.get(url)
答案 1 :(得分:0)
来自Scrapy doc:
无论此参数的类型如何,存储的最终值都将是 是一个str(从来没有unicode或None)。
如果您正在使用Scrapy,我假设您在Python中使用Selenium。您可以使用lxml或其他库解析response.body
字符串。 “让selenium使用response.body
”到底是什么意思?