オンラインチュートリアルに基づいていくつかのウェブスクレイピングコードを書いていますが、エラーが発生しています。私のコードは、オンラインにあるものとほぼ正確に一致しますが、まだエラーが発生しているようです。誰かが助けてくれますか?エラーの種類に基づいて、ファイル名とパスに関連しているようです。私はそこでさまざまな組み合わせを試みたが、まだエラーが発生しています。美味しいスープを使ったPythonのWebスクレイピングプログラムのエラー
下記のコードをコピーしました。
from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup
my_url = 'https://www.newegg.com/Video-Cards-Video-Devices/Category/ID-38?Tpk=graphics%20cards'
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
page_soup = soup(page_html, "html.parser")
containers = page_soup.finaAll("div", {"class":"item-container"})
filename = "C:\\Users\\_Alekhine_\\Python\\products.csv"
f = open(filename, "w")
headers = "brand, product_name, shipping\n"
f.write(" ")
for container in containers:
brand = container.div.div.a.img["title"]
title_container = container.findAll("a", {"class": "item-title"})
product_name = title_container[0].text
shipping_container = container.findAll("li", {"class": "price-ship"})
shipping = shipping_container[0].text.strip()
print("brand: " + brand)
print("product_name: " + product_name)
print("shipping: " + shipping)
f.write(brand + "" + product_name.replace(",", "") + "" + shipping + "\n")
f.close()
どのようなエラーが表示されますか?言いたいことが何か重要だと感じませんか? –