【发布时间】:2020-06-17 22:54:14
【问题描述】:
我正在尝试登录 beeradvocate.com 以抓取(抓取)一些啤酒数据。 我尝试使用硒,但一直失败。
这里是html
<input type="text" name="login" value="" id="ctrl_pageLogin_login" class="textCtrl" tabindex="1" autofocus="autofocus" style="background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGP6zwAAAgcBApocMXEAAAAASUVORK5CYII="); cursor: auto;">
我尝试使用名称、值和类,但一切都失败了。 我尝试了 Xpath 作为我的最后一次尝试,但也失败了。
我的代码:
driver=webdriver.Chrome("~~~~\\chromedriver.exe")
driver.get("https://www.beeradvocate.com/community/login/")
from selenium.common.exceptions import TimeoutException
driver.maximize_window()
while True:
try:
WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.XPATH,'//*[@id="ctrl_pageLogin_login"]'))).send_keys("scentmaster")
break
except TimeoutException:
print("too much time")
我已经让按钮工作了:
button = driver.find_element_by_xpath('//*[@id="pageLogin"]/dl[3]/dd/input')
driver.execute_script("arguments[0].click();", button)
但是,我需要能够执行 sent_keys 以输入 id 和 pw 以登录... 有人知道吗?
【问题讨论】:
标签: python selenium web-scraping beautifulsoup