我正在努力通过用and替换implicitly_wait
来加速 Selenium 网络抓取。我对如何实现这一目标有点困惑。WebDriverWait
send_keys
click
这是我的代码inplicitly_wait
:
def ncd_web_scraping(df):
df['new_column'] = 'Not_sure'
url = 'url'
for i in df.index:
driver = webdriver.Chrome()
driver.implicitly_wait(5)
driver.get(url)
name = driver.find_element_by_xpath('//*[@id="person"]')
name.send_keys(df.loc[i, 'Name'])
state = driver.find_element_by_xpath('//*[@id="state"]')
state.send_keys(df.loc[i, 'State'])
botton = driver.find_element_by_xpath('/html/body/div[2]/form/button')
botton.click()
soup = BeautifulSoup(driver.page_source, 'html.parser')
if soup.find('h5'):
df.loc[i, 'new_column'] = 'Yes'
else:
df.loc[i, 'new_column'] = 'No'
return df
谁能帮我webDriveWait
改写代码?
我感谢您的帮助。