Python script runs on Google Colab but not locally

98 views Asked by At

I was trying to run this script in a VS Code pyhton notebook and got that error.

import requests
import xmltodict
xml = requests.get('https://websvc.biocyc.org/getxml?id=META:TYRFUMCAT-PWY')
dbiocyc = xmltodict.parse(xml.text)

ExpatError: not well-formed (invalid token): line 24, column 65

Running it on Google Colab I got the right output.

Both at Python 3.10.12, xmltodict 0.13.0, requests 2.31.0

Someone can help me figure out why is it happening?

I was expecting get a dictionary with the information in the web page, but I got an error.


Update 1:

Following rasjani comment, I compared both requests.get() output saving them as a .xml file.

On Google Colab it was saving the page as it really is.

Locally, another page is being saved instead of the one I want, a HTML page, which has and XML forbidden character on line 24.

Left: File that I get running script locally -- Right: File that I get running at Google Colab - I want to get this locally

0

There are 0 answers