import urllib
from urllib2 import urlopen
from gzip import GzipFile
from cStringIO import StringIO
import re
import urllib2
def download(url):
s = urlopen(url).read()
if s[:2] == '\x1f\x8b': # assume it's gzipped data
with GzipFile(mode='rb', fileobj=StringIO(s)) as ifh:
s = ifh.read()
return s
s = download('http://www.locationary.com/place/en/US/Virginia/Richmond-page20/?ACTION_TOKEN=NumericAction')
findLoc = re.compile('http://www\.locationary\.com/place/en/US/Virginia/Richmond/.{1,100}\.jsp')
findLocL = re.findall(findLoc,s)
for i in range(0,25):
def download(url):
s = urlopen(url).read()
if s[:2] == '\x1f\x8b': # assume it's gzipped data
with GzipFile(mode='rb', fileobj=StringIO(s)) as ifh:
s = ifh.read()
return s
b = download(findLocL[i])
findYP = re.compile('http://www\.yellowpages\.com/.{1,100}\d{1,100}')
findYPL = re.findall(findYP,b)
for c in range(1):
print findYPL[c]
jacob501 0 Light Poster
jacob501 0 Light Poster
jacob501 0 Light Poster
jacob501 0 Light Poster
jacob501 0 Light Poster
TrustyTony 888 pyMod Team Colleague Featured Poster
jacob501 0 Light Poster
TrustyTony 888 pyMod Team Colleague Featured Poster
woooee 814 Nearly a Posting Maven
jacob501 0 Light Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.