【问题标题】:Scrape required information from website - Beautifulsoup从网站上抓取所需的信息 - Beautifulsoup
【发布时间】:2021-11-30 20:36:32
【问题描述】:

我想使用 Beautifulsoup 刮取“产品尺寸”信息,即“102.87 x 40.64 x 11.43 厘米;16.33 千克” - 下面是汤文字

输入:

输出:

{'Product Dimensions': '102.87 x 40.64 x 11.43 cm; 16.33 Kilograms'}

【问题讨论】:

  • 能否请您提供网站的网址和您的一些代码。如果还有其他方法,这将有助于澄清。谢谢

标签: python web-scraping beautifulsoup


【解决方案1】:

试试这样的。

el = soup.find('span', {'class': 'a-text-bold'})
el_k = el.text.replace(':', "").encode('ascii', 'ignore').strip().decode('utf-8')
el_v = el.find_next().text
d = {el_k:el_v}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-22
    • 2020-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-07
    • 1970-01-01
    相关资源
    最近更新 更多