Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> import urllib
- >>> data = urllib.urlopen("http://www.robert-king.com").read()
- >>> start = data.find("items = [")
- >>> end = data.find("]", start)
- >>> items = eval(data)
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- File "<string>", line 1
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
- ^
- SyntaxError: invalid syntax
- >>> items = eval(data[start: end])
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- File "<string>", line 1
- items = ['Hello World',
- ^
- SyntaxError: invalid syntax
- >>> items = eval(data[start: end].replace("items = ", ""))
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- File "<string>", line 11
- "The best way to destroy an enemy is to make him a friend."
- ^
- SyntaxError: invalid syntax
- >>> items = eval(data[start: end].replace("items = ", "") + "]")
- >>> from random import choice
- >>> while True:
- ... quote = choice(items)
- ... if quote == "Hello World":
- ... print quote
- ... break
- ...
- Hello World
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement