Markov Python Final Project


#1

This is my Markov Final Project. I intend to put this app on an html page and include that on my college resume. I would appreciate any suggestions you might have. I would also like feedback on any errors or issues you had while testing the code.
Follow the link to access the code on github here

fetch_data.py
import urllib2
from bs4 import BeautifulSoup

def get_data():
	site = raw_input('Enter lyric url here(azlyrics only): ')
	page = urllib2.urlopen(site)
	html_doc = page.read()
	soup = BeautifulSoup(html_doc, 'html.parser')
	a = soup.find_all('div')
	for div in a:
		if div.has_attr('class') == False and div.has_attr('id') == False:
			return div.get_text().encode('UTF-8')

run.py
"""
This program prompts you to insert lyric urls from azlyrics.
It mixes up the lyrics and gives you a new song in the same words by using a Markov Chain Generator
"""
from fetch_data import get_data
from markov_python.cc_markov import MarkovChain

num = int(raw_input("How many songs do you want to mash up? "))

def get_songs():
	for i in range(num):
		mc.add_string(get_data())

mc = MarkovChain()
get_songs()
output = mc.generate_text(num * 20)

print " ".join(output)


#2

I think it looks good. Keep up the good work