Skip to content

Instantly share code, notes, and snippets.

@ishashankverma
Created July 4, 2018 15:36
Show Gist options
  • Save ishashankverma/eac745d836b690d50bc2d1b768139182 to your computer and use it in GitHub Desktop.
Save ishashankverma/eac745d836b690d50bc2d1b768139182 to your computer and use it in GitHub Desktop.
Parse function for parsing ebox url
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