我使用selenium get网页,然后发送kenword获取新页面。但是我怎样才能得到新的网页,并搜索我需要的信息
browser = webdriver.Chrome()
test_url = 'https://www.baidu.com/'
browser.get(test_url)
in_put = browser.find_element_by_xpath('//*[@id="kw"]')
name = 'python'
in_put.send_keys(name.decode())
button = browser.find_element_by_xpath('//*[@id="su"]')
button.click()
page = browser.page_source
with open('baidu.html','wb') as f:
f.write(page)
原谅我没有使用降价。我的问题:我想在搜索关键字后得到网页,但我写browser.page_源,是百度的主页
要在python上使用selenium获取当前页面URL,请使用
而不是
^{pr2}$以下是更改后的代码:
输出:
相关问题 更多 >
编程相关推荐