当前使用Selenium + Python和以下代码:
browser.get('http://www.google.com')
search = browser.find_element_by_name('q')
search.send_keys("how to search the internet")
search.send_keys(Keys.RETURN) # hit return after you enter search text
time.sleep(5) # sleep for 5 seconds so you can see the results
browser.execute_script("window.scrollTo(0, 873)")
time.sleep(2)
browser.find_element(By.XPATH, '(//h3)[3]/a').click()`
作为我的代码。
发生什么:转到Google并输入单词并点击搜索。向下滚动一点,然后点击第一个链接
我想要的是:我希望能够从搜索结果页面中单击随机链接
这该怎么做?
编辑:这就是我说不必要时的意思:不必要的 1:https ://imgur.com/a/70qz89x
不必要的2:https : //imgur.com/a/8WWvcnC
这些是我想要的唯一结果:这个:https : //imgur.com/a/eTatFV9
相关分类