>>> 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 "", line 1, in File "", line 1 ^ SyntaxError: invalid syntax >>> items = eval(data[start: end]) Traceback (most recent call last): File "", line 1, in File "", line 1 items = ['Hello World', ^ SyntaxError: invalid syntax >>> items = eval(data[start: end].replace("items = ", "")) Traceback (most recent call last): File "", line 1, in File "", 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