r =requests.get("https://www.federalreserve.gov/fomc/minutes/1994/19940706min.htm")
c = r.content
soup= BeautifulSoup(c)
dates= soup.find_all("span", {"class" : "style1"})
committee = soup.find_all("div", {"class" : "committee" })
attendees= soup.find_all("div", {"class":"attendees"})
text = soup.find_all("p")
minutesDate = [i.get_text() for i in dates]
minutesCommittee = [j.get_text() for j in committee]
minutesAttendees = [k.get_text() for k in attendees]
minuteText=[m.get_text() for m in text]
new_dict = {k: v for k, v in zip(minutesDate, minutesCommittee)}
使用上面的代码,我想创建一个minutesDate键并附加其他值 - minutesCommittee,minutesAttendees,minuteText。我尝试使用defaultdict和setdict收集包,由于某种原因,我无法弄清楚如何将这些值绑定到这一个键。
答案 0 :(得分:0)
你想要的是一个dicts的词典:
minutes = {minuteDate1: {minutesCommitee: [...], minutesAttendees = [...], ...},
minuteDate2: {minutesCommitee: [...], minutesAttendees = [...], ...}}