from urllib import urlretrieve
import urllib2
import re
import gzip
urlretrieve('http://www.locationary.com/place/en/US/Virginia/Richmond-page28/?ACTION_TOKEN=NumericAction', 'myfile')
page = gzip.open('myfile', 'rb').read()
findLoc = re.compile('http://www\.locationary\.com/place/en/US/Virginia/Richmond/.{1,100}\.jsp')
findLocL = re.findall(findLoc,page)
listIterator = []
listIterator[:] = range (0,25)
for i in listIterator:
urlretrieve(i, 'myfile2')
page2 = gzip.open('myfile2', 'rb').read()
findYP = re.compile('http://www\.yellowpages\.com.{1,100}\d{1,100}')
findYPL = re.findall(findYP,page2)
listIterator2 = []
listIterator2[:] = range(0,1)
for i in listIterator2:
print findYPL[i]
print "\n"
When I load this code, I get the following error from Python:
Traceback (most recent call last):
File "C:\Users\Robert\Documents\python\locationary.py", line 38, in <module>
urlretrieve(i, 'myfile2')
File "C:\Python27\lib\urllib.py", line 91, in urlretrieve
return _urlopener.retrieve(url, filename, reporthook, data)
File "C:\Python27\lib\urllib.py", line 225, in retrieve
url = unwrap(toBytes(url))
File "C:\Python27\lib\urllib.py", line 1038, in unwrap
url = url.strip()
AttributeError: 'int' object has no attribute 'strip'
What did I do wrong and how can I fix this?
Help would be greatly appreciated. Thanks!