リンクからいくつかのデータを削り取ろうとしています:http://www.airlinequality.com/airline-reviews/vietjetair/?sortby=post_date%3ADesc&pagesize=100 たとえば、私はBeautifulSoupを使って各レビューアの名前を抽出しようとしていますが、動作しません。私は他のウェブサイトでBeautifulSoupを使う前に試してみました。私は何が起こっているのか分からない。手伝って頂けますか。コードは以下の通りです:Beautifulsoup-Pythonでラッピングする
from bs4 import BeautifulSoup
import os
import urllib.request
file1 = open(os.path.expanduser(r"~/Desktop/Skytrax Reviews1.csv"), "wb")
file1.write(b"Reviewer" + b"\n")
WebSites = ["http://www.airlinequality.com/airline-reviews/vietjetair/?sortby=post_date%3ADesc&pagesize=100"]
# looping through each site until it hits a break. I will create a loop. It is not ready yet
for theurl in WebSites:
thepage = urllib.request.urlopen(theurl)
print(thepage)
soup = BeautifulSoup(thepage,'lxml')
print(soup) #<-------This is the main problem
#Maybe it is not correct too but the main problem is at the above lines
for Reviewer in soup.findAll(attrs={"class": "text_sub_header userStatusWrapper"}).text:
print(Reviewer)
Record1 = Reviewer
file1.write(bytes(Record1, encoding="ascii", errors='ignore') + b"\n")
file1.close()
。私はあなたのものと同じリンクを使用してPythonで新しいです。 –