使用selenium获取不到response

overus 2018-05-09 12:23:25
在做scrapy+selenium+Phantomjs的爬虫时遇到一个问题,按照网上别人的爬虫自己做了一个,但是不能获取正确的
response,小白请大神帮忙看看哪出了问题?

输出的部分结果:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<200 http://yuehui.163.com/searchusers.do>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


爬虫:
class YhSpider(scrapy.Spider):
name = 'yh'
allowed_domains = ['http://yuehui.163.com']
start_urls = ['http://yuehui.163.com/searchusers.do']
def parse(self, response):
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print(response)
print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")

下载中间件:
class PageMiddleware(object):
def process_request(self, request, spider):
driver = webdriver.PhantomJS()
driver.get(request.url)
driver.find_element_by_xpath("//select[@name='province']/option[@value='2']").click()
driver.find_element_by_xpath("//div[@class='btnblock']/button[@id='commonsearchbtn']").click()
time.sleep(2)
content = driver.page_source.encode("utf-8")
driver.quit()
return HtmlResponse(request.url, encoding="utf-8",body=content, request=request)
...全文
1001 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
response.body
overus 2018-05-09
  • 打赏
  • 举报
回复
原来如此,多谢了!

37,720

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧