Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib2, string, webbrowser, time, sys, thread
- x = 1
- while True:
- #print "Downloading new list."
- while x == 1:
- print """WELCOME TO WIKIPEDIA RANDOM LIST GENERATOR
- Press enter to skip article
- type in any letter and press enter to view article
- """
- print "Downloading new list."
- random_list = urllib2.urlopen("http://en.wikipedia.org/w/api.php?action=query&list=random&rnnamespace=0&rnlimit=10&format=json").read()
- print"""Download complete
- ************************"""
- break
- #def listget():
- random_list2 = urllib2.urlopen("http://en.wikipedia.org/w/api.php?action=query&list=random&rnnamespace=0&rnlimit=10&format=json").read()
- #return random_list
- #thread.start_new_thread(listget,(),)
- #print"Download complete"
- #print random_list
- letters = 10
- while letters > 0:
- idstr = '"id":'
- end_idstr = ',"ns"'
- id_location = random_list.find(idstr)
- end_id_location = random_list.find(end_idstr)
- spot_of_id = id_location + 5
- ID_code = random_list[spot_of_id:end_id_location]
- #print "ID:", random_list[spot_of_id:end_id_location]
- random_list = random_list[end_id_location:]
- namestr = '"title":"'
- end_namestr = '"}'
- name_location = random_list.find(namestr)
- end_name_location = random_list.find(end_namestr)
- spot_of_name = name_location + 9
- name = random_list[spot_of_name:end_name_location]
- #print "Name:", random_list[spot_of_name:end_name_location]
- print """
- """
- decision = raw_input(name)
- decision.upper()
- if decision == "":
- random_list = random_list[end_name_location:]
- letters = letters - 1
- elif decision == "QUIT":
- sys.exit()
- else:
- website = "http://en.wikipedia.org/wiki?curid=" + ID_code
- webbrowser.open(website)
- random_list = random_list2
- x=10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement