ValueError:无法将输入数组从形状(4)广播到形状(9)

时间:2019-12-18 08:32:42

标签: python web-scraping

我实际上是在从购物网站Flipkart抓取数据,并将其保存到包含产品名称,价格和等级的products.csv文件中。

for a in soup.find_all("a", href = True, attrs = {"class" : "_31qSD5"}):
   name = a.find("div" , attrs = {"class":"_3wU53n"})
   price = a.find("div" , attrs = {"class":"_1vC4OE _2rQ-NK"})
   rating = a.find("div" , attrs = {"class":"hGSR34"})
   products.append(name.text)
   prices.append(price.text)
   rating.append(rating.text)


df = pd.DataFrame({"Product_Name":products, "Prices":prices, "Ratings":rating})

上面的代码运行良好,但是下面的行给出了此错误:

ValueError: could not broadcast input array from shape (4) into shape (9)

0 个答案:

没有答案