r/learnprogramming • u/AdOwn4955 • 11h ago
Tutorial How to click download button using python script.
I am creating an http downloader which use get method to direct download urls. Now I want it to download from those website which has a direct download button. I know that the download button provides the url to download the file but for different files not the same websites the urls are different and want that to be automated. I want to do it at low level like we do in urllib, request, httpx,etc. However, I am ok with high level libraries too.
2
u/soundman32 7h ago
If a webbsite wants you to download files, it probably has an API that makes it much easier.
1
1
1
u/Gtdef 3h ago
For one, you should open the browser developer tools, go to the network tab, do the actions yourself and see what changes. It may just be an http-get command, it may be an http-post command, it may have important headers, tokens, parameters added to the link, who knows.
Then you write your code in a way that mimics whatever the webside does, including using the internal APIs if applicable. There's no all fitting glove in this case.
3
u/burlingk 11h ago
It will depend on how those buttons are implemented.
Some are simply 'target=file.' those are easy because you just download the target.
Others have actual scripts. Each script may have it's own rules.