Skip to content

Instantly share code, notes, and snippets.

@vim13
Created September 29, 2010 20:33
Show Gist options
  • Save vim13/603499 to your computer and use it in GitHub Desktop.
Save vim13/603499 to your computer and use it in GitHub Desktop.
allcinema
#!/usr/lib/python
#vim:fileencoding=utf-8
import urllib2
import re
from BeautifulSoup import BeautifulSoup
class Cinema:
def __init__(self):
url = 'http://www.allcinema.net/prog/index2.php'
self.soup = BeautifulSoup(urllib2.urlopen(url))
def getTitle(self):
node = self.soup.find('ul', {'class': 'toprankinglist'})
res = re.search(u'href="(.*?)".*?>(.*?)</a>', str(node))
return 'http://www.allcinema.net/prog/' + res.group(1), res.group(2)
if __name__ == '__main__':
obj = Cinema()
obj.getTitle()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment