Skip to content

Instantly share code, notes, and snippets.

@jrabbit
Created August 16, 2010 03:38
Show Gist options
  • Select an option

  • Save jrabbit/526353 to your computer and use it in GitHub Desktop.

Select an option

Save jrabbit/526353 to your computer and use it in GitHub Desktop.
Return the movie of the week
from BeautifulSoup import BeautifulSoup
import re
import urllib2
import urllib
def grab(user, passwd):
o = urllib2.build_opener( urllib2.HTTPCookieProcessor() )
urllib2.install_opener( o )
values = {'username' : user, 'password' : passwd}
url = 'https://tehconnection.eu/login.php'
data = urllib.urlencode(values)
o.open(url, data)
f = o.open('https://tehconnection.eu/index.php')
the_page = f.read()
f.close()
return the_page
def motw(user, passwd):
html = grab(user, passwd)
soup = BeautifulSoup(html)
#find <div class="alertbar notify_box">
#<a href="torrents.php?id=525">Lord of War</a> is the movie of the week! </div>
motw = soup.findAll('div', 'alertbar notify_box')[0].['a'].contents
return motw
if __name__ == "__main__":
import sys
user = sys.argv[1]
passwd = sys.argv[2]
print motw(user, paswd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment