Hi, I'm new to Python and am having trouble with this.
Here's my code:
import urllib, urllib2, re
import xml.etree.ElementTree as ET
from bs4 import BeautifulSoup
# The get_zipcode(address) function will be called with an address string with
# no zip code, such as 'Lowell Observatory, Flagstaff, AZ', and it should return the
# ZIP code of the address as a string
# For example, get_zipcode('Lowell Observatory, Flagstaff, AZ') should return '86001'
# Use the Google Geocoding API to obtain the ZIP code. Documentation:
# https://developers.google.com/maps/documentation/geocoding/
# Can use either json or xml output format.
def get_zipcode(address):
zipcode = ''
url_values = urllib.urlencode(address)
url="http://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false" % address
#return zipcode
response = urllib2.urlopen(url)
return response
I'm getting an error and don't really know how to continue to get the output I want. Especially with extracting the zip code from the json output. Any help would be greatly apprecited!
3
Contributors
3
Replies
21 Hours
Discussion Span
3 Months Ago
Last Updated
6
Views
Question Answered
Related Article:Python data extraction help
is a Python discussion thread by Triarius_1 that has 6 replies, was last updated 6 months ago and has been tagged with the keywords: python, program, data, extraction, help, urgent.
Actually, I solved the zipcode part. I ended up using the xml output to grab the data. :D
But now I really have no idea how to get the current weather conditions from the rss weather feed.
Right now, this is my code:
I have to go to the item tag that has the Current weather conditions (from http://rss.weather.com/weather/rss/local/92802) and then grab the link under that tag, but I don't know how to do either especially since it has this weird <![CDATA[ in front.