rkd77 / elinks

Fork of elinks
Other
349 stars 38 forks source link

Is there any way to download a file non interactively #123

Closed mayureshw closed 3 years ago

mayureshw commented 3 years ago

On some URLs where wget/curl/python fail to download a binary file at the URL (presumably as the server snubs them), elinks downloads the file correctly (although interactively).

I also tried using a different browser identification strings in wget/curl/python so that the server doesn't snub those clients, including using the identity string of elinks, but it did not work.

It will be nice if elinks lets download the file non-interactively. elinks -dump -color-mode 0 does not help, as it shows ASCII text for the file. I just need to download it exactly as the download dialogue in elinks does, but wish to do it non interactively so that I can embed it in a script.

rkd77 commented 3 years ago

You can check: elinks --source URL > file wget or curl are better for it.

mayureshw commented 3 years ago

Well I made it clear. My question starts with, when wget/curl/python don't work but elinks does.

rkd77 commented 3 years ago

Some examples please. Likely cookies are required or correct HTTP-Referer. python-requests are best candidate IMO. If you insist on ELinks. add pre_format_html_hook in your favourite scripting language. This hook can save files. Start normal elinks session, and in script call elinks --remote with appropriate command. Not tested at all, just guess.

mayureshw commented 3 years ago

Example: https://www.valueresearchonline.com/downloads/fund-selector-xls/?source_url=/funds/selector-data/primary-category/1/equity?fund-house=&tab=snapshot

There is no particular reason to use elinks, other than that curl/wget/python did not work, after trying to set their identity to firefox/elinks etc while elinks works. If you can advise options of any of these, I can use those as well.

rkd77 commented 3 years ago

Does ELinks login on this page automatically, or you must click something?

rkd77 commented 3 years ago

In src/network/socket.c there is: / To enable logging of tranfers, for debugging purposes. /

if 0

^^^^^ set this to 1

2) set connection.max_connections = 1 set connection.max_connections_to_host = 1 disable compression

recompile elinks.

Run ELinks and get some logs in /tmp/log . Later see what ELinks sends and what it receives, especially in headers and write script, for example in python, which do similar things. No other ideas.

mayureshw commented 3 years ago

Does ELinks login on this page automatically, or you must click something?

Oh sorry, I didn't realize the cookie was lurking in my .elinks/cookies. I thought it's a public link. So, I can try and use that cookie with wget/curl/python and that should solve it.