[Tutor] Using Python to access .txt files stored behind a firewall as .exe files

Alan Gauld alan.gauld at yahoo.co.uk
Mon May 1 20:36:06 EDT 2017

On 02/05/17 01:12, Ian Monat wrote:

> 1) Use Python to download the file from the web (but not by using a
> webscraper, according to Alan)

Things like BeautifulSoup will help you read the HTML and
extract links etc but they won't help you actually fetch
the file/documents from the web site. A package like
requests is the correct tool for that.

> 2) Simply ignore the .exe wrapper and use, maybe Windows Task Manager, to
> unzip the file and place the .txt file in the desired folder

I don't think Task Manager will do it but third party tools
exist that can and they cope with self executing zip files
too. And you can execute those programs from Python rather
than directly executing the unsafe download and, if its not
a legitimate zip file they will usually just issue a warning.

Once you have a regular zip file the standard Python zip module
can extract the text file.

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list