Quite new to Python and scraping but have so far got this code together to get the artist and title of the song off the site.
When I run the code I get first a list of the artists followed by a list of the titles.
My question is: how do I get these results into a database or a csv file?
I have notebook++ working for python, plus pycharm and idle and this bit of code works OK with all three. Any suggestions most welcome.
from urllib import urlopen
from bs4 import BeautifulSoup
html = urlopen("http://www.officialcharts.com/charts/singles-chart/19800203/7501/" )
bsObj = BeautifulSoup(html)
nameList = bsObj. findAll("div" , {"class" : "artist",})
for name in nameList:
print(name. get_text())
html = urlopen("http://www.officialcharts.com/charts/singles-chart/19800203/7501/" )
bsObj = BeautifulSoup(html)
nameList = bsObj. findAll("div" , {"class" : "title"})
for name in nameList:
print(name. get_text())