【发布时间】:2019-07-17 00:12:02
【问题描述】:
我在 Python 中使用 Selenium 进行网页抓取。我正在使用 xpath 来提取网站的部分内容。
我想知道如何使用循环提取 URL 列表并将它们保存到字典中。
mylist_URLs = ['https://www.sec.gov/cgi-bin/own-disp? action=getowner&CIK=0001560258',
'https://www.sec.gov/cgi-bin/own-disp?action=getissuer&CIK=0000034088',
'https://www.sec.gov/cgi-bin/own-disp?action=getissuer&CIK=0001048911']
我下面的编码仅适用于 1 个网址...
driver = webdriver.Chrome(r'xxx\chromedriver.exe')
driver.get('https://www.sec.gov/cgi-bin/own-disp?action=getowner&CIK=0000104169')
driver.find_elements_by_xpath('/html/body/div/table[1]/tbody/tr[2]/td/table/tbody/tr[1]/td')[0].get_attribute('innerHTML')
感谢您的帮助。
【问题讨论】: