/[svn.andrew.net.au]/scripts/movies.py
ViewVC logotype

Annotation of /scripts/movies.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 49 - (hide annotations)
Sun Mar 21 16:14:37 2010 UTC (12 years, 6 months ago) by apollock
File MIME type: text/x-python
File size: 1037 byte(s)
Rewrote to use BeautifulSoup. Now works with latest incarnation of the site

1 apollock 6 #!/usr/bin/python
2    
3 apollock 49 import BeautifulSoup
4     import urllib2
5 apollock 6 import time
6     import datetime
7     import xml.sax.saxutils
8    
9     def main():
10 apollock 49 imdb = urllib2.urlopen("http://www.imdb.com/nowplaying/")
11     soup = BeautifulSoup.BeautifulSoup("".join(imdb.readlines()))
12     moviestuff = soup.findAll("table")[0]
13     moviestuff.table.extract()
14     movies = xml.sax.saxutils.escape(moviestuff.prettify())
15 apollock 6 print """<?xml version="1.0" encoding="utf-8"?>
16     <feed xmlns="http://www.w3.org/2005/Atom">
17    
18     <link href="http://home.andrew.net.au/~apollock/movies.xml" rel="self"/>
19    
20     <title>This week's movies from IMDb</title>
21     <updated>%(updated)sZ</updated>
22     <author>
23     <name>Andrew Pollock</name>
24     </author>
25     <id>http://www.andrew.net.au/</id>
26    
27     <entry>
28 apollock 49 <id>http://home.andrew.net.au/movies/%(timestamp)s</id>
29 apollock 6
30     <updated>%(updated)sZ</updated>
31     <title>This week's movies</title>
32    
33     <content type="html">
34     %(movies)s
35     </content>
36     </entry>
37     </feed>
38 apollock 16 """ % { 'updated': datetime.datetime.utcnow().isoformat()[0:19], 'movies': movies, 'timestamp': int(time.time()) }
39 apollock 6
40     if __name__ == "__main__":
41     main()

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.22