title: download articles from wikipedia using special export
body: <p>I want to be able to download full histories of a few thousand articles from <a href="http://en.wikipedia.org/wiki/Special:Export" rel="nofollow">http://en.wikipedia.org/wiki/Special:Export</a> and I am looking for a programmatic approach to automate it. I want to save result as XML.</p>
  
  <p>Here is my <a href="http://en.wikipedia.org/w/index.php?title=Special%3aExport&amp;addcat&amp;catname=English-language_Indian_films&amp;action=submit" rel="nofollow">Wikipedia query</a>. I started the following in Python, but that doesn't get any useful result.</p>
  
  <pre><code>#!/usr/bin/python
  
  import urllib
  import codecs
  
  f =  codecs.open('workfile.xml', 'w',"utf-8" )
  
  class AppURLopener(urllib.FancyURLopener):
      version = "Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"
  urllib._urlopener = AppURLopener()
  
  query = "http://en.wikipedia.org/w/index.php?title=Special:Export&amp;action=submit"
  data = { 'catname':'English-language_Indian_films','addcat':'', 'wpDownload':1 }
  data = urllib.urlencode(data)
  f = urllib.urlopen(query, data)
  s = f.read()
  print (s)
  </code></pre>