Is there a Julia function that makes as if I were clicking on a web link?

Viewed 50

I want to use an API to generate csv files that are downloaded when I click on a web link. I have the code which generates the link as a string, and I am now searching a way to make a code that goes automatically to the link to download the csv file instead of me clicking on the link ?

1 Answers

You can download any link by Julia using Downloads module (or HTTP.jl for more complex cases).

import Downloads
io = IOBuffer()
your_url = "https://stackoverflow.com/robots.txt"
Downloads.download(your_url, io)

Let's give it a look for the first 100 downloaded bytes:

julia> println(String(io.data[1:100]))
User-Agent: *
Disallow: /posts/
Disallow: /posts?
Disallow: /amzn/click/
Disallow: /questions/as

If you actually want to do the "browser clocking", you need to use a browser robotization tool. Perhaps the most popular is Selenium. You could install it in Python and load through PyCall

Related