Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to get addresses from a webpage for mapping purposes. I know I could copy and paste the addresses into an Excel file and geocode them but I was wondering if there was any faster way to get the address from a webpage and create a point location file.

Thanks in advance.

share|improve this question
    
It all depends on how the addresses are formatted on said web page, but yes parsing addressing into a .csv and then geocoding is quite possible. –  MLowry Jan 23 '12 at 19:15
2  
It sounds like you are talking about web scraping. If that is the case, which isn't really a GIS question, consider asking the question over at StackOverflow, or searching their tags screen-scraping and web-scraping. –  RyanDalton Jan 23 '12 at 19:41
    
as above, but it's fairly easy to write a small app that looks at a specific part of a web page and disemintaes the information. –  Hairy Jan 24 '12 at 12:15

1 Answer 1

up vote 7 down vote accepted

This should get you started. Python and the BeautifulSoup module to the rescue. The code below will print out a list of the 26 addresses on that webpage. I used Firebug in Firefox to look at the page source, which told me that the cell width was 37%. I gambled that those cells were maybe the only ones at 37% width, and was right. You should be able to feed the list of addresses you get into a online geocoder and get point locations.

enter image description here

import BeautifulSoup as bs
import urllib2

url = 'http://www.phillypal.com/pal_locations.php'

response = urllib2.urlopen(url)
html = response.read()
soup = bs.BeautifulSoup(html)

addresses = soup.findAll('td', {'width':'37%'})

print len(addresses)

for address in addresses:
    print address.find(text=True)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.