我需要从搜索输入刮谷歌的建议。现在我使用selenium+phantomjswebdriver。你知道吗
search_input = selenium.find_element_by_xpath(".//input[@id='lst-ib']")
search_input.send_keys('phantomjs har python')
time.sleep(1.5)
from lxml.html import fromstring
etree = fromstring(selenium.page_source)
output = []
for suggestion in etree.xpath(".//ul[@role='listbox']/li//div[@class='sbqs_c']"):
output.append(" ".join([s.strip() for s in suggestion.xpath(".//text()") if s.strip()]))
但我在firebug XHR请求中看到类似this。和响应-简单的文本文件的数据,我需要。然后我看看日志:
selenium.get_log("har")
我看不到这个请求。我怎么能抓住它?我需要这个url作为模板使用的请求库使用它与其他搜索词。或者可以运行js,用其他参数(不是从输入字段)启动这个请求,是吗?你知道吗
你只能用Python+Selenium+PhantomJS来解决这个问题。你知道吗
以下是我为实现这一目标所做的工作清单:
工作方案:
印刷品:
相关问题 更多 >
编程相关推荐