Reputation: 29
I am trying to access an xml file (many actually) from an online source. I had a code that would do it but i installed a fresh OS and forgot to back up my phython scripts :(
I am literally just trying to access the xml, once I have the data i believe i remember how i parsed it. I just can't remember how i accessed it. I've been looking around and all i can find is stuff in the urllib but when i try to make a request it wont run the script because of the ':' in the web address. Any help??
here is one of the xml addresses I'm trying to access. http://api.eve-central.com/api/marketstat?typeid=34®ionlimit=10000002
Upvotes: 0
Views: 2819
Reputation: 4120
The urllib2 library is what you are looking for.
http://docs.python.org/2/howto/urllib2.html
Briefly, this is how you use itL
url_response = urllib2.urlopen(url) ## return a http.response object
xml_content = url_response.read() ## read the content
In addition, I uses beautifulsoup4 to pull out data from the xml doc http://www.crummy.com/software/BeautifulSoup/bs4/doc/ .
Briefly,
from bs4 import BeautifulSoup ## import bs4 as BeautifulSoup
content = BeautifulSoup(xml_content) ## convert xml content to beautifulsoup object
span = content.find_all("span") ## find all span tag and return as list
Cheer!
Upvotes: 3