【发布时间】:2019-05-24 06:13:27
【问题描述】:
Here 是我要为其提取按钮链接文本的链接,但我无法这样做 网站打开后,我从“选择产品”中选择一个选项,假设我选择第一个选项,即“丙烯酸涂料”,然后出现 3 种类型,即“底漆”、“中间体”、“饰面”, 我想提取他们无法做到的文本。
import requests
from bs4 import BeautifulSoup
driver = webdriver.Chrome('~/chromedriver.exe')
driver.get('http://www.asianpaintsppg.com/applications/protective_products.aspx')
lst_name = ['Acrylic Coatings','Glass Flake Coatings']
for i in lst_name:
print(i)
driver.find_element_by_xpath("//select[@name='txtProduct']/option[text()="+"'"+str(i)+"'"+"]").click()
page = requests.get("http://www.asianpaintsppg.com/applications/protective_products.aspx")
soup = BeautifulSoup(page.content, 'html.parser')
for div in soup.findAll('table', attrs={'id':'dataLstSubCat'}):
print(div.find('a')['href'])
但我在这里得到空值。 任何帮助将不胜感激。
【问题讨论】:
-
我想这会对你有所帮助:Previously asked similar question
标签: python-3.x selenium-webdriver web-scraping beautifulsoup web-crawler