Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions