This program basically takes lyrics from three different songs and uses markov chains to generate a verse influenced by all three songs. It's super basic and I still to add some finishing touches to make it pretty, like outputting the verse somewhere blah blah. Had a lot of help from the codeacademy admins thanks so much guys! Would appreciate any feedback!
p.s. Not sure how this formatting works haha.
#fetch data from url then write to file def get_data(lyrics1, lyrics2, lyrics3): import urllib2 response1 = urllib2.urlopen(lyrics1) response2 = urllib2.urlopen(lyrics2) response3 = urllib2.urlopen(lyrics3) html1 = response1.read() html2 = response2.read() html3 = response3.read() from bs4 import BeautifulSoup soup1 = BeautifulSoup(html1, 'html.parser').get_text() soup2 = BeautifulSoup(html2, 'html.parser').get_text() soup3 = BeautifulSoup(html3, 'html.parser').get_text() final = soup1 + soup2 + soup3 return final
#runs project and outputs text import fetch_data from markov_python.cc_markov import MarkovChain lyrics1 = raw_input("Input link to lyrics: ") lyrics2 = raw_input("Input link to lyrics: ") lyrics3 = raw_input("Input link to lyrics: ") mc = MarkovChain() mc.add_string(fetch_data.get_data(lyrics1, lyrics2, lyrics3)) print mc.generate_text()