[英]Get data from list using beautifulsoup in python
I have the webpage- https://dmesupplyusa.com/mobility/bariatric-rollator-with-8-wheels.html Here there is a list of specifications under details that i want to extract as a table, ie the specification category as the header, and the specification value as the next row.我有网页-https://dmesupplyusa.com/mobility/bariatric-rollat or-with-8-wheels.html 这里有一个详细的规格列表,我想提取为表格,即规格类别为header,规格值作为下一行。 How can i do this in python using beautifulsoup?我如何使用 beautifulsoup 在 python 中执行此操作?
import requests
import pandas as pd
from bs4 import BeautifulSoup as bs
page = requests.get("https://dmesupplyusa.com/mobility/bariatric-rollator-with-8-wheels.html").content #Read Page source
page = bs(page) # Create Beautifulsoup object
data = page.find_all('strong', string="Product Specifications")[0].find_next('ul').text.strip().split('\n') # Extract requireed information
data = dict([zip(i.split(":")) for i in data])
df = pd.DataFrame(data).T
I hope this is what you are looking for.我希望这就是你要找的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.