简体   繁体   中英

Scrape required information from website - Beautifulsoup

I want to scrape "Product Dimensions" information which is "102.87 x 40.64 x 11.43 cm; 16.33 Kilograms" using Beautifulsoup - below is the soup text

Input: 在此处输入图像描述

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

Try something like this.

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}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM