0

So basically, I'm trying to download a file from a website It's quite simple there is just a download button. However the problem is that this download button doesn't directly lead to the file URL but actually leads to an empty page where a download token is given and a download suddenly pops (the page doesn't get redirected to that token) see Image

I tried simply using requests.get() but that seems to download the html page rather than the file (it doesn't get redirected to the file) then I tried scraping that empty page for anything that could help but it just seems empty there is nothing there but html and body tags I'm trying to use selenium but I still don't know how to "catch" that download Maybe I could click the button and wait for the automated browser (Chrome) to start the download and then get the download url from the browser somehow, maybe with a js script (I'm aware that I'll have to turn off my download manager) but I don't know how or what js script I'll use.

Jimmynoarms
  • 169
  • 1
  • 7
  • Check if this [link](https://stackoverflow.com/questions/36309314/set-firefox-profile-to-download-files-automatically-using-selenium-and-java) is helpful. You need to setup the firefox options. – supputuri Jul 24 '19 at 14:02
  • This does work but It's not what I want and It's not something I can't already do with chrome I didn't ask how to start a download through chrome I asked how to get the url from a download in chrome (start the download in chrome then get the link from there it'd be the equivalent of right clicking an ongoing download in chrome and then clicking (Copy download url) ) – Jimmynoarms Jul 24 '19 at 14:21
  • Ok, so you need the url of the download source in chrome. Correct? If the answer is yes, then you can check [this](https://stackoverflow.com/questions/56543995/how-to-get-the-url-or-filename-being-downloaded-now/56554342#56554342) – supputuri Jul 24 '19 at 14:23
  • Yep, that's the one ,it would be a lot better if you could run it before the download is complete, still it'll do for now. – Jimmynoarms Jul 24 '19 at 15:19
  • [Upvote](https://stackoverflow.com/help/why-vote) the answer if the referred answer is/was helpful to you for the benefit of the future readers. – supputuri Jul 24 '19 at 15:35
  • Other approach would be, in FF when you click on the button switch to the latest window and get the title. And split it `/` and then get the last matching item `[-1]`. – supputuri Jul 24 '19 at 15:37

0 Answers0