0

Trying to re-polish my python skills (been working mostly in R until now) but ended up with a bunch of errors..

I want to download this the file from here and convert it to a simple table (or dataframe). At first sight, it seems to be an xml file but python doesn't recognize it as an xml file. I tried this code:

import requests
url = 'http://utilitytool.casc.eu/CascUtilityWebService.asmx/GetNetPositionDataForAPeriod?dateFrom=2016-09-01&dateTo=2016-09-03'

r = requests.get(url)
print (r.content)

and it shows the data from that website in a text file format. Now I'd like to convert it to a simple table (or dataframe) with the column names: ns1:CalendarDate, ns1:CalendarHour, ns1:BE, ns1:NL, ns1:DEAT and ns1:FR

I googled a bunch of errors, tried all options from here but still didn't find a solution..

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
nick
  • 1,090
  • 1
  • 11
  • 24
  • Per the duplicate, requests does not parse xml, so you will need to use another module. The duplicate answer addresses this. – idjaw Oct 02 '16 at 21:50
  • Try using beautifulsoup aka bs4. `from bs4 import BeautifulSoup; soup = Beautifulsoup(r.text)`. To help you get started check out their awesome tutorial: https://www.crummy.com/software/BeautifulSoup/ – imant Oct 02 '16 at 21:53

0 Answers0