Advertisement
Guest User

Jeopardy Extraction

a guest
Aug 23rd, 2011
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. #Jeopardy!
  2. #Goal is to create a list of lists ie.
  3. #[[Category 1, Question 1, Answer 1], [Category 1, Question 2, Answer 2]]
  4. #First iteration will just be Q
  5.  
  6.  
  7. import urllib.request, re
  8.  
  9. Question = []
  10.  
  11. first_game_id = 3458
  12. last_game_id = 3713
  13.  
  14. for gameid in range(first_game_id, last_game_id):
  15.     webpageid = "http://www.j-archive.com/showgame.php?game_id=" + str(gameid)
  16.     temp=urllib.request.urlopen(webpageid)
  17.     webpage=temp.read()
  18.     temp.close()
  19.     for line in webpage:
  20.         if question != None:
  21.             Question.append(question)
  22. print(Question)
  23.  
  24. #wrong.  ??? = figure out which re to insert?
  25.  
  26. question = re.match('clue_text\"></td>')
  27. answer= re.match'correct_response&quot;&gt;???&'
  28.  
  29.  
  30. #trying to use re match and compile to match the string and output tuple?
  31. import urllib.request, re
  32. webpageid = "http://www.j-archive.com/showgame.php?game_id=" + str(3713)
  33. temp=urllib.request.urlopen(webpageid)
  34. webpage=temp.read()
  35. temp.close()
  36.  
  37. question=re.compile(r'clue_text">*?</td>')
  38.  
  39. Question = []
  40. ##
  41. ##for line in webpage:
  42. ##    print(line)
  43. ##    
  44. ##    if question.match(line) != None:
  45. ##        Question.append(question)
  46. ##
  47. ##print(Question)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement