Reading data from URL

前端 未结 5 1330
情深已故
情深已故 2021-02-19 00:59

Is there a reasonably easy way to get data from some url? I tried the most obvious version, does not work:

readcsv(\"https://dl.dropboxusercontent.com/u/.../test         


        
5条回答
  •  别那么骄傲
    2021-02-19 01:37

    The Requests package seems to work pretty well. There are others (see the entire package list) but Requests is actively maintained.

    Obtaining it

    julia> Pkg.add("Requests")
    
    julia> using Requests
    

    Using it

    You can use one of the exported functions that correspond to the various HTTP verbs get, post, etc which returns a Response type

    julia> res = get("http://julialang.org")
    Response(200 OK, 21 Headers, 20913 Bytes in Body)
    
    julia> typeof(res)
    Response (constructor with 8 methods)
    

    And then, for example, you can print the data using @printf

    julia> @printf("%s",res.data);
    
    
    
      
    ...
    

提交回复
热议问题