i am getting special symbols in csv
don;t know y
can u help me in his
from urllib.request import urlopen
android_url = “https://en.wikipedia.org/wiki/Android_version_history”
android_data = urlopen(android_url)
print(android_data)
android_html = android_data.read()
print(android_html)
android_data.close()
from bs4 import BeautifulSoup as soup
a_soup = soup(android_html,‘html.parser’)
print(a_soup)
alen = a_soup.findAll(‘table’,{‘class’:‘wikitable’})
print(len(alen))
a_table = alen[0]
print(a_table)
headerList = a_table.findAll(‘th’,{})
h1 = [h.text[:-1] for h in headerList]
print(h1)
rc = a_table.findAll(‘tr’,{})[1:]
#print(rc)
tr = []
for rd in rc:
rowdata = [ r.text[:-1] for r in rd.findAll(‘td’)]
tr.append(rowdata)
print(tr)
filename = “android_history.csv”
with open(filename,‘w’,encoding=‘utf-8’) as f:
hdstr = “,”.join(h1)
hdstr+="\n"
print(hdstr)
f.write(hdstr)
for s in tr:
r1 = ",".join(s)
r1+="\n"
f.write(r1)