为了账号安全,请及时绑定邮箱和手机立即绑定

HTML类的网页抓取问题

HTML类的网页抓取问题

慕容森 2021-08-05 16:22:24
import pandas as pdimport requestsfrom bs4 import BeautifulSoupres = requests.get("https://www.digikey.com/products/en/inductors-coils- chokes/fixed-inductors/71/page/1")soup = BeautifulSoup(res.content,'lxml')table = soup.find_all('table')[0] df = pd.read_html(str(table))[0]part_numbers = df["Manufacturer Part Number"].tolist()manufacturer = df["Manufacturer"].tolist()quantity_available = df["Quantity Available"].tolist()m_qty = df["Minimum Quantity"].tolist()types = df["Type"].tolist()material = df["Material - Core"].tolist()inductance = df["Inductance"].tolist()tolerance = df["Tolerance"].tolist()current_rating = df["Current Rating"].tolist()current_saturation = df["Current - Saturation"].tolist()shielding = df["Shielding"].tolist()resistances = df["DC Resistance (DCR)"].tolist()freq = df["Q @ Freq"].tolist()frequency = df["Frequency - Self Resonant"].tolist()ratings = df["Ratings"].tolist()operating_temperature = df["Operating Temperature"].tolist()i_frequency = df["Inductance Frequency - Test"].tolist()mounting_type = df["Mounting Type"].tolist()package = df["Package / Case"].tolist()s_package = df["Supplier Device Package"].tolist()size_dimension = df["Size / Dimension"].tolist()height = df["Height - Seated (Max)"].tolist()unit_price = df["Unit Price,USD"].tolist()我正在尝试网络抓取,但我不知道如何导入单价,您可以看到在代码的末尾,其他工作正常,但单价代码不起作用;我必须弄清楚 HTML 代码,我该如何描述?另外,我需要一个循环来下载接下来的多个页面。
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 150 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信