File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change
1
+ '''Author Anurag Kumar(mailto:anuragkumarak95@gmail.com)
2
+ Module for Fetching Random Wiki Pages and asking user for opening one of them
3
+
4
+ Python:
5
+ - 3.5
6
+
7
+ Requirements:
8
+ - requests
9
+ - json
10
+ - webbrowser
11
+
12
+ Usage:
13
+ - $python3 wiki_random.py
14
+
15
+ enter index of article you would like to see, or 'r' for retry and 'n' for exit.
16
+ '''
1
17
import requests , json , webbrowser
2
18
3
- url = 'https://en.wikipedia.org/w/api.php?action=query&list=random&rnnamespace=0&rnlimit=10&format=json'
19
+ page_count = 10
20
+ url = 'https://en.wikipedia.org/w/api.php?action=query&list=random&rnnamespace=0&rnlimit=' + str (page_count )+ '&format=json'
4
21
5
22
def load ():
6
23
response = requests .get (url )
@@ -16,7 +33,7 @@ def load():
16
33
print ('Auf Wiedersehen!' )
17
34
return
18
35
else :
19
- try : int (i )
36
+ try : jsonData [ int (i )][ 'id' ]
20
37
except Exception : raise Exception ("Wrong Input..." )
21
38
print ('taking you to the browser...' )
22
39
webbrowser .get ().open ('https://en.wikipedia.org/wiki?curid=' + str (jsonData [int (i )]['id' ]))
You can’t perform that action at this time.
0 commit comments