Question: I am doing my paper for C996 programming in python. I was able to write the code but I am not able to deduplicate the
I am doing my paper for C996 programming in python. I was able to write the code but I am not able to deduplicate the links and also export the links to the CSV file. below is my code. can you please advise me in what i need to add.
importrequests
frombs4importBeautifulSoup,SoupStrainer
importbs4,csv
search_link="https://www.census.gov/programs-surveys/popest.html"
r=requests.get(search_link)
raw_html=r.text
soup=BeautifulSoup(raw_html,"html.parser")
all_links=soup.find_all("a")
forlinkinsoup.find_all('a'):
print(link.get_text())
#print(all_links)']
withopen('links.csv','w',newline='')ascsvFile:
wr=csv.writer(csvFile,quoting=csv.QUOTE_ALL)
forlinkinsoup.find_all('a'):
wr.writerow(link)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
