yan*_*ngm 2 python browser selenium
我试图在Web数据库中运行python程序以获取结果表。我的问题是在不实际打开浏览器的情况下如何获得结果?有没有更简单的方法来获取表格结果?我想获取最底表的值(例如,BCS类,溶解度,剂量等)。(结果的底部没有td.text,所以我不能使用find next si兄命令。)谢谢!这是我的代码:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
driver= webdriver.Chrome()
driver.get('http://www.ddfint.net/search.cfm')
search_form=driver.find_element_by_name('compoundName')
search_form.send_keys('Abacavir')
search_form.submit()
page= BeautifulSoup(driver.page_source, 'html.parser')
page.find("td", text="Lowest Solubility (mg/ml):").find_next_sibling("td").text
Run Code Online (Sandbox Code Playgroud)
您可以尝试添加--headless参数,ChromeOptions以告知浏览器不渲染。
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
driver = webdriver.Chrome(chrome_options=chrome_options)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
99 次 |
| 最近记录: |