Created
July 4, 2018 15:36
-
-
Save ishashankverma/eac745d836b690d50bc2d1b768139182 to your computer and use it in GitHub Desktop.
Parse function for parsing ebox url
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import xml.etree.ElementTree as ET | |
url = 'http://test.cognizant.e-box.co.in/uploads/data_usage.xml' | |
# Getting the xml data from url | |
req = requests.get(url) | |
text = req.text | |
# Parsing the xml | |
root = ET.fromstring(text) | |
root_tag = root.tag | |
for customers in root: | |
customer_id = [v for k, v in customers.attrib.items()] | |
print(customer_id) | |
for customer in customers: | |
if customer.tag == 'limit': | |
limit = customer.text | |
print(limit) | |
else: | |
for usage in customer: | |
if usage.tag == 'date': | |
date = usage.text | |
print(date) | |
elif usage.tag == 'pulse': | |
pulse = usage.text | |
print(pulse) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment