首页 文章

如何在Julia后面的代理中发出HTTP请求?

提问于
浏览
0

朱莉娅诺布,只是尝试了几个简单的练习 .

我正在尝试运行以下代码:

using HTTP
url = "https://finance.yahoo.com/quote/googl"
r = HTTP.request("GET", url)

并获得超时错误 .

一些评论:

  • 我支持公司代理 . 我已经设置了http_proxy和https_proxy(以及它们的大写等价物),并且我已经使.gitconfig文件知道这些设置 .

  • 使用Python urllib2的等效代码没有问题 .

  • 试过网址的http版本 - 没有运气 .

  • 试过POST而不是GET - 仍然没有运气 .

  • 详细选项未显示任何额外信息 .

这是堆栈跟踪的顶部:

错误:LoadError:IOError:connect:连接超时(ETIMEDOUT)Stacktrace:1 try_yieldto(:: typeof(Base.ensure_rescheduled),:: Base.RefValue )at . /event.jl:196 [2]等待()at ./event.jl:255 [3] wait(:: Condition)at . / event.jl:46 [4] stream_wait(:: Sockets.TCPSocket,:: Condition)at ./stream.jl:47 [5] wait_connected(:: Sockets.TCPSocket)at ./stream.jl:263 [6] connect at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Sockets/src/Sockets . jl:444 [inlined] [7] connect(:: Sockets.IPv4,:: UInt64)at / buildworker / worker / package_linux64 / build / usr / share / julia / stdlib /v1.0/Sockets/src/Sockets.jl :428 [8] #getconnection#14(:: Bool,:: Int64,:: Base.Iterators.Pairs {Symbol,Union {Nothing,Bool},Tuple {Symbol,Sy mbol},NamedTuple {(:require_ssl_verification,: iofunction),Tuple {Bool,Nothing}}},:: Function,:: Type ,:: SubString ,:: String)athome/T2213331/.julia/packages/HTTP/ nUK4f / src / ConnectionPo ol.jl:548

this SO question我已确认 ENV["http_proxy"]ENV["https_proxy"] 都已正确设置 .

1 回答

  • 1

    这似乎有效

    HTTP.get("https://finance.yahoo.com/quote/googl", proxy="http://123.123.123.123:8888")
    

    当然,您需要提供正确的代理IP和端口 .

相关问题