The server employs User-Agent sniffing; it looks at the User-Agent header and if it doesn't like what it sees it'll return an empty response.

You can set the header yourself:

Copyimport urllib2
import shutil

headers = {'User-Agent': 'Mozilla'}
urlfile = "http://www.equibase.com/premium/eqbLateChangeXMLDownload.cfm"

request = urllib2.Request(urlfile, headers=headers)
response = urllib2.urlopen(request)
with open("c:\\test.xml", 'wb') as outfile:
    shutil.copyfileobj(response, outfile)

The 'Mozilla' User-Agent string is apparently enough to convince the server to serve the file.

I used a combination of urllib2 (an updated version of the urllib library) and shutil.copyfileobj() to handle setting additional headers, then copying the response data to a file. urllib.urlretrieve() does not support adding headers, and urllib2 has no urlretrieve() equivalent.

Answer from Martijn Pieters on Stack Overflow
🌐
Pybites
pybit.es › articles › download-xml-file
How to Download an XML File with Python – Pybites
May 4, 2017 - The nicer and Pythonic thing to do is to have a separate script that does the request once and saves the required data to a local file. Your primary scraping or analysis script then references the local file. ... import requests URL = "http://insert.your/feed/here.xml" response = requests.get(URL) with open('feed.xml', 'wb') as file: file.write(response.content)
Discussions

Building a URL that downloads an XML File
Do you have a web server? You just need to upload your xml file, link to the file, and it will be downloaded by whoever uses the link; no programming needed. More on reddit.com
🌐 r/learnpython
4
0
September 27, 2022
How to download from the XML url using python - Stack Overflow
I am trying to extract from the URL I am trying to get the download from the first URL which file_type file_type is DLTINS Below is the code import requests import xml.etree.ElementTree as ET resp... More on stackoverflow.com
🌐 stackoverflow.com
python - XML download from a url - Stack Overflow
I have written a code to download XML file from a website and store into database. But before download, I should parse the user credentials to the website. The code is working properly but I am unable to find the XML downloaded path. can you help me on this. users are loaded from MySQL database. url... More on stackoverflow.com
🌐 stackoverflow.com
xml parsing - Downloading XML file with Python 3 - Stack Overflow
I am trying to make a python 3.3 program to download a XML file, parse it, and display the info. I know how to parse the file but I am having downloading the file and converting it to parse-able XML. Here is what I have so far. import xml.etree.ElementTree as ET import webbrowser,time,urllib.req... More on stackoverflow.com
🌐 stackoverflow.com
May 23, 2017
🌐
GitHub
gist.github.com › MichelleDalalJian › f587530b6e0a72357541f39b2022aa55
Extracting Data from XML: The program will prompt for a URL, read the XML data from that URL using urllib and then parse and extract the comment counts from the XML data, compute the sum of the numbers in the file. · GitHub
url = "http://py4e-data.dr-chuck.net/comments_1659064.xml" serviceurl = urllib.request.Request(url) uh = urllib.request.urlopen(url, context=ctx) data = uh.read() #print('Retrieved', len(data), 'characters') #print(data.decode()) tree = ET.fromstring(data) lst = tree.findall('comments/comment') #print('User count:', len(lst)) for item in lst: #print('Numero:', item.find('count').text) sum = sum + int(item.find('count').text) print("Total:",sum)
🌐
Reddit
reddit.com › r/learnpython › building a url that downloads an xml file
r/learnpython on Reddit: Building a URL that downloads an XML File
September 27, 2022 -

Hi!

I'm trying to figure out how to set up a URL that when hit downloads an XML file. I think I would use something like Flask to set this up, but am not quite sure if that's correct

Would love some help figuring out exactly how I can set this up. Thanks!

🌐
LinkedIn
linkedin.com › pulse › downloading-parsing-xml-file-using-python-tkinter-murat-yaşar
Downloading And Parsing XML File Using Python & Tkinter
March 9, 2018 - http://eli.thegreenplace.net/2012/03/15/processing-xml-in-python-with-elementtree ... The following urls contains the information about this import statement. What it is and why we need it are being explained on these urls. ... After importing the necessary modules, I wrote the below code. I downloaded the xml data and converted it to an xml element hierarchy called ElementTree.
Find elsewhere
🌐
Sec-api
sec-api.io › resources › download-xml-files-from-sec-edgar-with-python
Download XML Files from SEC EDGAR Using Python
Welcome to this tutorial on downloading XML files from the SEC EDGAR database using Python. In this tutorial, we will walk you through the process of using the Query API to find and extract all XML file URLs from ABS-EE filings for the year 2022, and then using the Render API to download all the corresponding XML files.
🌐
Real Python
realpython.com › python-download-file-from-url
How to Download Files From URLs With Python – Real Python
January 25, 2025 - In this tutorial, you'll find the right tools to help you download files from URLs with Python and manage the data retrieval process. You'll cover data streaming, thread pools, and asynchronous downloads.
🌐
TechTrek
techtrek.io › how-to-parse-xml-data-with-python-from-url
How to Parse XML Data with Python From URL - TechTrek
March 5, 2020 - The XML module will be used for dealing with the data and the URL module is so that we can open the URL. Alternatively, you may have the XML saved in a .XML file.
🌐
Stack Overflow
stackoverflow.com › questions › 51524366 › how-to-download-a-xml-file-http
python 2.7 - How to download a XML file http? - Stack Overflow
July 26, 2018 - import requests from tqdm import tqdm url = "http://software.broadinstitute.org/gsea/msigdb/download_file.jsp?filePath=/resources/msigdb/6.2/msigdb_v6.2.xml" response = requests.get(url, stream=True) with open("lol.xml", "wb") as handle: for data in tqdm(response.iter_content()): handle.write(data)
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-download-files-from-urls-with-python
How to Download Files from Urls With Python - GeeksforGeeks
July 23, 2025 - Whether using the straightforward urllib.request, the versatile requests library, or specialized modules like wget and urllib3, developers have the flexibility to choose an approach that best suits their needs. Armed with these techniques, efficiently incorporating file downloads into Python applications becomes a seamless and accessible task.
🌐
GitHub
gist.github.com › ayubmetah › feb8cd2daf9297f1338bcbccec029567
write a Python program to prompt for a URL, read the XML data from that URL using urllib and then parse and extract the comment counts from the XML data, compute the sum of the numbers in the file. · GitHub
Download ZIP · write a Python program to prompt for a URL, read the XML data from that URL using urllib and then parse and extract the comment counts from the XML data, compute the sum of the numbers in the file.
🌐
Medium
medium.com › @myagubbayli › parsing-xml-files-from-urls-in-python-using-beautiful-soup-library-export-data-to-excel-c76b476eada0
Parsing XML files from Urls in Python using Beautiful Soup library & Export data to Excel | by Mahammad Yagubbayli | Medium
November 16, 2022 - You can write the URL you want to apply in the URL. Then we get the response with “requests.get”. The “.content” is exporting the XML structure. With “find_all” we get all the tags and their content that we want to get.