Alex Hall, 27.01.2011 05:01:
How would I go about getting the xml from a website through the site's
api? The url does not end in .xml since the xml is generated based on
the parameters in the url. For example:
https://api.website.com/user/me/count/10?api_key=MY_KEY
would return ten results (the count parameter) as xml. How do I
actually get this xml into my program? TIA.

The filename extension doesn't matter. If you know it's XML that you get back, you can use ElementTree (in the xml.etree package) or lxml (external package) to read it. Use the urllib2 package in the standard library to request the XML page, then pass the result into the XML parser (parse()).

Stefan

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to