Created
October 18, 2011 02:42
-
-
Save alexle/1294489 to your computer and use it in GitHub Desktop.
Web scraper for Criminal Minds show times (ION)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from urllib import urlopen | |
import re, time | |
LINK = 'http://www.ionline.tv' # url to scrape | |
SHOW = 'CRIMINAL MINDS' # show keyword to search on | |
msg = SHOW | |
show_index = 0 | |
content = urlopen( LINK ).read() | |
dates_array = re.findall( 'weekdate">(.*?)<', content ) | |
time = re.findall( 'title">(.*?)<.*?eastern">(.*?)<.*?(/ul|<li)', content ) | |
for date_entry in range( len(dates_array) - 1 ): | |
msg += '\n' + dates_array[date_entry] # iterate through dates | |
while True: | |
if ( time[show_index][0] == SHOW ): # check if show is CM | |
msg += '\n' + time[show_index][1] | |
show_index += 1 | |
if ( time[show_index-1][2] == '/ul' ): # marker for end of day | |
break | |
print msg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment