我试图通过使用类名来获得它。但是没有得到任何回应
代码如下:
from requests import get
import requests
from bs4 import BeautifulSoup
import csv
url = 'https://www.hydraulichoses.com/sae100-r2s-2-wire-hydraulic-hoses-p/r2s.htm'
soup = BeautifulSoup( requests.get(url).content, 'lxml')
product_category = ''
product_category = soup.find('td', class_ = 'vCSS_breadcrumb_td').findAll('a')[1].text.strip()
product_title = soup.find('td', class_ = 'vCSS_breadcrumb_td').find('h1').text
print(soup.find('table', class_ = 'product-table'))
这是第二张表:
这些表没有类或id,因此需要以其他方式搜索它们
例如:
印刷品:
您必须通过
css selector
在soup
中查找这两个表现在,您在一个
tables
变量中迭代以获取所需的内容此页中有两个以上的表。您通常需要检查代码以查看需要哪些表
在您的情况下,您似乎在
tables[7]
和tables[11]
之后相关问题 更多 >
编程相关推荐