Permalink
Browse files

Make random pages more random

  • Loading branch information...
1 parent 82e7e0c commit 3e210046c9d370c1fe87352749846c5e112da11f @wjt committed Feb 18, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 longwitton/views.py
View
@@ -24,9 +24,15 @@ def status(request):
})
def reset(request):
- r = urllib.urlopen('http://www.wikirandom.org/json?pages=3')
+ r = urllib.urlopen(
+ 'http://en.wikipedia.org/w/api.php?format=json&action=query&list=random&rnlimit=3&rnnamespace=0')
json = r.read()
- urls = re.findall(r'http://en.wikipedia.org/wiki[^"]+', json)
+ print json
+ titles = re.findall(r'"title":"[^"]+', json)
+
+ print titles
+ urls = map(lambda t: 'http://en.wikipedia.org/wiki/' + t[9:].replace(' ', '_'), titles)
+ print urls
g = get_game()
g.goal = urls[0]

0 comments on commit 3e21004

Please sign in to comment.