Selenium卡在.get(url)上

时间:2018-03-01 19:17:45

标签: python-2.7 selenium selenium-webdriver selenium-chromedriver

我试图用一个登录字段抓取一个网站,如果我关闭驱动程序并每次重新打开它(每次登录),那么它工作正常,但如果我尝试继续使用相同的驱动程序然后它被卡在.get(url)请求上。

DRIVER = selenium.webdriver.Chrome()

def login(url):
   DRIVER.get(url)
   username = DRIVER.find_element_by_name('login')
   password = DRIVER.find_element_by_name('passwd')
   username.send_keys('justinalexander')
   password.send_keys('sin4546')
   form = DRIVER.find_element_by_name('blogin')
   form.click()
   time.sleep(5)
return

def main():
   login(url)
   data = DRIVER.page_source
   soup = BeautifulSoup(data, "html.parser")
   print("1")
   DRIVER.get(url2) # this page does open in the chrome window
   print("2") # code never reaches here

0 个答案:

没有答案