我有一个文本文件,其中包含四个地址的列表。请参见下面的屏幕截图:
在我的硒刮刀中,我将每个地址作为密钥传递。addresselements.send_keys(lines)。运行 selenium 驱动程序时,它仅从我的文本文件和浏览器中获取第一个地址。
这是我的完整代码的摘要:
from selenium import webdriver
driver = webdriver.Chrome
url ="my terget url"
driver.get(url)
addressElement = driver.find_elements_by_css_selector('#search-input-adresse')
#impoting address from text file
f = open('address.txt')
lines = f.readline()
for addresselements in addressElement:
addresselements.send_keys(lines) #enter your address
addresselements.send_keys(Keys.ENTER)
我如何将所有地址一一循环。我也尝试过这段代码但没有用
f = open('address.txt')
lines = f.readline()
for line in f:
for addresselements in addressElement:
addresselements.send_keys(lines) #enter your address
addresselements.send_keys(Keys.ENTER)
慕桂英3389331
相关分类