Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2012
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. >>> import urllib
  2. >>> data = urllib.urlopen("http://www.robert-king.com").read()
  3. >>> start = data.find("items = [")
  4. >>> end = data.find("]", start)
  5. >>> items = eval(data)
  6. Traceback (most recent call last):
  7.   File "<stdin>", line 1, in <module>
  8.   File "<string>", line 1
  9.     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
  10.     ^
  11. SyntaxError: invalid syntax
  12. >>> items = eval(data[start: end])
  13. Traceback (most recent call last):
  14.   File "<stdin>", line 1, in <module>
  15.   File "<string>", line 1
  16.     items = ['Hello World',
  17.           ^
  18. SyntaxError: invalid syntax
  19. >>> items = eval(data[start: end].replace("items = ", ""))
  20. Traceback (most recent call last):
  21.   File "<stdin>", line 1, in <module>
  22.   File "<string>", line 11
  23.     "The best way to destroy an enemy is to make him a friend."
  24.                                                               ^
  25. SyntaxError: invalid syntax
  26. >>> items = eval(data[start: end].replace("items = ", "") + "]")
  27. >>> from random import choice
  28. >>> while True:
  29. ...     quote = choice(items)
  30. ...     if quote == "Hello World":
  31. ...         print quote
  32. ...         break
  33. ...
  34. Hello World
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement