Skip to content

Instantly share code, notes, and snippets.

@alexle
Created October 18, 2011 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexle/1294489 to your computer and use it in GitHub Desktop.
Save alexle/1294489 to your computer and use it in GitHub Desktop.
Web scraper for Criminal Minds show times (ION)
#!/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