我试图用一个登录字段抓取一个网站,如果我关闭驱动程序并每次重新打开它(每次登录),那么它工作正常,但如果我尝试继续使用相同的驱动程序然后它被卡在.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