【问题标题】:Get data from list using beautifulsoup in python在python中使用beautifulsoup从列表中获取数据
【发布时间】:2020-07-03 06:58:58
【问题描述】:

我有网页-https://dmesupplyusa.com/mobility/bariatric-rollator-with-8-wheels.html 这里有一个详细信息下的规范列表,我想提取为表格,即规范类别作为标题,规范值作为下一行。我如何在 python 中使用 beautifulsoup 做到这一点?

【问题讨论】:

    标签: python web-scraping beautifulsoup html-lists


    【解决方案1】:
    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
    

    我希望这就是你要找的。​​p>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-11
      • 2021-01-05
      • 1970-01-01
      相关资源
      最近更新 更多