Like this?
#!/usr/bin/env python
import urllib
def save_page(site="http://www.tvrage.com/Warehouse_13/episode_list"):
mypath = site
f = open('temp2.txt', 'w')
for item in urllib.urlopen(mypath).readlines():
f.write(item)
f.close()
def find_title(temp="temp2.txt"):
f = open(temp)
site = f.readlines()
f.close()
for item in site:
if item.find('<title>') != -1:
before_html, tag_before, rest_html = str(item).partition('<title>')
title, tag_after, after_html = rest_html.partition('</title>')
print 'Title:', title
def find_episodes(temp="temp2.txt"):
f = open(temp)
site = f.readlines()
f.close()
for item in site:
if item.find('''onmouseover="showToolTip2(event,'View Trailer');return false;" onmouseout="hideToolTip2();" ></a> <a href='/Warehouse_13/episodes/''') != -1:
before_html, tag_before, rest_html = str(item).partition('''onmouseover="showToolTip2(event,'View Trailer');return false;" onmouseout="hideToolTip2();" ></a> <a href='/Warehouse_13/episodes/''')
title, tag_after, after_html = rest_html.partition('</a> </td>')
print 'Episodes:', title[12:]
save_page()
find_title()
find_episodes()
Happy coding.
Beat_Slayer
Posting Pro in Training
405 posts since Jun 2010
Reputation Points: 30
Solved Threads: 105