1

What I am trying to do...

I am trying to automate a download of a zip file from a URL that does not redirect the URL, but instead opens up a "Save as" prompt the moment you open the URL.

What I have tried...

"Urllib request", "Wget", and "Requests" libraries are all giving me a 1KB file which in a text editor reads "Invalid request". This could make sense as the Website URL I am inputting is blank by default, and I don't believe its redirecting the URL to anywhere as I had "allow_redirects=True" using the "Requests" Library. I believe this link is using JavaScript to redirect to the "Save as" and when I click it and head to downloads (In Chrome) and see that there is a download link for this file. This download link appears to always work but I am unsure how to grab it with Python.

Leads...

I have found a lead in Stack Overflow about using the library "Spynner", but I am not sure HOW and WHY that would solve my problem.

I am using Python 3.8.2

halfer
  • 19,824
  • 17
  • 99
  • 186

2 Answers2

1

You need a web scraping tool. They usually have headless browsers and everything you need to "bot like" human behaviour. I would recommend Selenium because you can use it from python directly; here is an example: File managing Selenium.

Be careful, web scraping is not completely legal so you should have authorization to use it on any web service. Proceed with caution.

halfer
  • 19,824
  • 17
  • 99
  • 186
1

Like Juan said, I just needed to use a web scraping tool. After learning selenium I was able to bypass the save as requirement.