1
我是新来的蟒蛇和硒真的很享受学习一点。Python +硒,打开浏览器,然后什么都不做
只是把我的脚趾浸入硒,并有一些麻烦让这个脚本工作。
它没有给出错误,它只是打开浏览器,什么都不做。
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
kw = input("enter the keyword to search on google")
# creates firefox session
driver = webdriver.Firefox(executable_path=r'C:\Users\Web\Desktop\geckodriver-v0.18.0-win32\geckodriver.exe')
driver.implicitly_wait(30)
# navigate to google
driver.get("http://www.google.com")
#get the search textfield
search_field = driver.find_element_by_id("lst-ib")
search_field.clear()
#enter search kw and submit
search_field.send_keys(kw)
search_field.submit()
lists = driver.find_element_by_class_name("_Rm")
print ("Found " + str(len(lists)) + "searches:")
i=0
for listitem in lists:
print(listitem)
i=i+1
if(i>10):
break
driver.quit()
更新壁虎驱动程序和浏览器。 –