0
私はウェブサイトからデータを取得し、それをtsvファイルに書き出しています。しかし、私のコードは、セット全体ではなく、最初のセットだけを返します。 助けてください。BeautifulSoupは最初の結果のみを返します
BASE_URL = "http://www.parliament.go.ke/index.php/the-national-assembly/house-business/hansard"
#Read base_url into Beautiful soup Object
html = urllib.request.urlopen(BASE_URL).read()
soup = BeautifulSoup(html, "html.parser")
#grab <div class="itemList"> that hold links and dates to all hansard pdfs
hansards = soup.find_all("div","itemList")
#Get all hansards
#write to a tsv file
with open("hansards.tsv","wt") as f:
fieldnames = ("date","hansard_url")
output = csv.writer(f, delimiter="\t")
for div in hansards:
hansard_link = [BASE_URL + div.a["href"]]
hansard_date = soup.find("h3", "catItemTitle").string
output.writerow([hansard_date,hansard_link])
print(hansard_date)
print(hansard_link)
print ("Done Writing File")