【发布时间】:2020-01-24 15:22:49
【问题描述】:
我正在尝试从here 和here 两个页面中抓取“活动”文本框。
我写了代码的基础:
options = Options()
options.binary_location=r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
options.add_experimental_option('excludeSwitches', ['enable-logging'])
#options.add_argument("--headless")
driver = webdriver.Chrome(options=options,executable_path='/mnt/c/Users/kela/Desktop/selenium/chromedriver.exe
url = 'http://www.uwm.edu.pl/biochemia/biopep/peptide_data_page1.php?zm_ID=' + str(i) #where str(i) is either 2500 or 2700 in this example
driver.get(url)
header = driver.find_element_by_css_selector('[name="activity"]')
children = header.find_elements_by_xpath(".//*")
我有两个问题:
- 我只需要拉出“选项选定值”的活动项,我不希望所有活动都返回。
- 但是如果选项是列表中的第一项,例如此处显示的活动为“aami”的页面之一; “选定值”不是一个选项,因为它是默认值。
所以我一直在寻找一两行代码,我可以添加到我的脚本中来提取:
neuropeptide | ne
alpha-amylase inhibitor | aami
来自这两个网页,如果有人可以提供帮助的话。
【问题讨论】: