【问题标题】:How does one fetch a web page in Julia?如何在 Julia 中获取网页?
【发布时间】:2015-05-20 10:47:28
【问题描述】:

我正在开发一个在 Julia 中获取和解析网页的应用程序。我想学习如何获取 url,以及如何从 Julia 中的身份验证代理之外获取 url。

【问题讨论】:

  • 这个问题感觉像是在求教程,其实不太适合 StackOverflow。我怀疑这就是它被否决的原因。就目前而言,您似乎并没有遇到任何具体问题。
  • 可能是downloadhttps://github.com/JuliaWeb/LibCURL.jl

标签: http url request fetch julia


【解决方案1】:

基本方法可能是这样的。这是使用 JSON 和 Requests 包访问 Reddit 的猫论坛“aww”:

using JSON, Requests

subreddit  = "aww"
first_request = get("http://www.reddit.com/r/$(subreddit)/new/.json")
request_json = JSON.parse(first_request.data)

for children in request_json["data"]["children"]
    for child in children["data"]
        if first(child) == "title" println(last(child)) end
    end
end

具有可预测的结果:

Zeus this is reddit, reddit meet Zeus
My blue eyed baby all grown up :)
She had a long walk (:
Charley isn't too picky with where he sleeps
My puppy accidentally did a role-poly
Meet Oliver, Oliver Wood.
Happy World Turtle Day!
Check out my new adorable boxer pup!
My handsome guard cat was being all picturesque this morning
Fluffy cow!
Our Husky/St Bernard mix named Gracie.
Tuxedo Derp!
She just wanted to snuggle and go to sleep. He wasn't having it.
Milo Greetings
This cat has prettier eyes than any human.
20+ Asshole Cats Being Shamed
Too bad this isn't a trick and it's actually stuck to his nose.
Blue family!
Just a puppy eating ice cream

【讨论】:

  • 感谢您的帮助。恐怕我没有完全完成就提交了我的问题。我在一个代理后面,它不允许我使用 julia 命令行从 github 获取任何包。所以我的问题真的是:如何从 github 复制 Requests 包的文件并创建适当的文件夹结构来使用它?我搜索了网络,但找不到任何好的答案。
猜你喜欢
  • 2022-01-16
  • 2015-10-16
  • 1970-01-01
  • 2011-06-15
  • 1970-01-01
  • 2023-01-12
  • 2021-08-11
  • 2017-11-22
  • 1970-01-01
相关资源
最近更新 更多