我需要获得div
标签之间的价格(61,990),但是如何摆脱货币符号?
与此处相同,我只需要获得评分(4.7),但此后我就不需要任何内容,例如img src
。我怎么能忽略它?还是跳过它?
代码示例:
from bs4 import BeautifulSoup
import requests
price = []
ratings=[]
response = requests.get("https://www.flipkart.com/laptops/~buyback-guarantee-on-laptops-/pr?sid=6bo%2Cb5g&uniq")
soup = BeautifulSoup(response.text,'html.parser')
for a in soup.findAll('a',href=True,attrs={'class':'_31qSD5'}):
price=a.find('div',attrs={'class':'_1vC4OE _2rQ-NK'})
rating=a.find('div',attrs={'class':'hGSR34'})