Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6562549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:43:21+00:00 2026-05-25T13:43:21+00:00

trying to scrape this xml file on the web with urllib and cElementTree. I

  • 0

trying to scrape this xml file on the web with urllib and cElementTree. I am using Google App Engine but I don’t think the problem is relevant to my platform.

This is my error:

<type 'exceptions.SyntaxError'>: not well-formed (invalid token): line 1, column 25
Traceback (most recent call last):
  File "/base/data/home/apps/metautoit/daily-update.353244196034914877/Start_Update.py", line 25, in main
    ShoppingCar.XMLRipper().getNew()
  File "/base/data/home/apps/metautoit/daily-update.353244196034914877/updatecars/sitecrawlers/ShoppingCar.py", line 24, in getNew
    for carDict in newCars:
  File "/base/data/home/apps/metautoit/daily-update.353244196034914877/updatecars/sitecrawlers/ShoppingCar.py", line 67, in _iter_carDicts_in_xml
    tree = self.get_xml()
  File "/base/data/home/apps/metautoit/daily-update.353244196034914877/updatecars/sitecrawlers/ShoppingCar.py", line 63, in get_xml
    return ET.parse(req, parser=parser)
  File "<string>", line 45, in parse
  File "<string>", line 28, in parse

The xml file is long but here is a sample:

<?xml version="1.0" encoding="windows-1252"?><veicoli>
<veicolo>
    <id><![CDATA[16529]]></id>
    <link><![CDATA[http://www.shoppingcar.it/auto_usate_/Chrysler_PT_Cruiser/16529.asp]]></link>
    <marca><![CDATA[Chrysler]]></marca>
    <modello><![CDATA[PT Cruiser]]></modello>
    <versione><![CDATA[2.4 L]]></versione>
    <provincia><![CDATA[Padova]]></provincia>
    <anno><![CDATA[2006]]></anno>
    <mese><![CDATA[4]]></mese>
    <chilometri><![CDATA[26000]]></chilometri>
    <cilindrata><![CDATA[]]></cilindrata>
    <potenza><![CDATA[143]]></potenza>
    <alimentazione><![CDATA[Benzina]]></alimentazione>
    <cambio><![CDATA[Cambio Automatico]]></cambio>
    <colore><![CDATA[nero]]></colore>
    <prezzo><![CDATA[14900]]></prezzo>
    <immagine><![CDATA[http://www.shoppingcar.it/public/Auto%20Usate/Berline/imagesadv/16529_2.jpg]]>
    </immagine>
</veicolo>
</veicoli>

My (simplified) code looks like this:

xml_url =   "http://www.shoppingcar.it/feed/export_vel.asp?parametro=1"
req =       urllib.urlopen(xml_url)
parser =    ET.XMLParser(encoding="windows-1252")
tree =      ET.parse(req, parser=parser).get_xml()

Here’s the kicker: I downloaded and uploaded it as a public dropbox file. Using this url the xml parses just fine. I’ve tried without declaring the encoding, and tried windows-1252 and utf-8 encodings. It’s just really strange because column 25 is nothing but the middle of the word “encoding”. Any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:43:22+00:00Added an answer on May 25, 2026 at 1:43 pm

    I tried your code (added imports, so that others can try):

    #!/usr/bin/env python
    import xml.etree.cElementTree as ET
    import urllib
    
    xml_url =   "http://www.shoppingcar.it/feed/export_vel.asp?parametro=1"
    req =       urllib.urlopen(xml_url)
    parser =    ET.XMLParser(encoding="windows-1252")
    tree =      ET.parse(req, parser=parser).get_xml()
    

    and it runs just fine. If your error only happens on the server then you probably hit a limit at the webpage and are trying to parse an error-message. So make sure that you are actually parsing the document (e.g. data = req.read() and then dump data and parse the string as xml.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to scrape a price from a web page using PHP and Regexes.
I'm trying to scrape using Google I'm Feeling Lucky button. For small query like
I am trying to scrape form field IDs using Beautiful Soup like this for
I'm trying to scrape the price field from this website using the HTML Agility
I am trying to scrape a company web page for automation purposes but the
I am trying to scrape this web page: http://www.acttab.com.au/interbet/venues?day=today Here is my code: function
I'm trying to scrape a quote engine but HttpWebResponse returns only the please wait
I'm trying to scrape some tables (election data) using the XML package. Browsing SO,
Trying to install Scrapy on Mac OSX 10.6 using this guide : When running
Hi I am trying to scrape other people web pages (for the forces of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.