lolamontes69

Python/ Find Url: Python Challenge 4

May 19th, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. import urllib
  2.  
  3. def find_the_url():
  4.     global numero
  5.     escape = 0
  6.     list1 = []
  7.     searchphrase = 'next nothing is'
  8.     while escape == 0:
  9.         locallist = []
  10.         url = "http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing="+str(numero)
  11.         conn = urllib.urlopen(url)
  12.         for line in conn.fp:
  13.             line = line.strip()
  14.             locallist.append(line)
  15.         conn.close()
  16.         text5 = '\n'.join(locallist)
  17.         if searchphrase in text5:
  18.             win = text5.find(searchphrase)
  19.             list1 = []
  20.             for a in text5[win:]:
  21.                 if a.isdigit():
  22.                     list1.append(a)
  23.             numero = ''.join(list1)
  24.             print numero,"    ",text5
  25.         else:
  26.             print text5
  27.             escape = 1
  28.  
  29. numero = 12345
  30. #numero = 8022
  31. find_the_url()
  32.  
  33. """
  34. look for number after 'next nothing is'
  35. """
Advertisement
Add Comment
Please, Sign In to add comment