gpt4 book ai didi

ruby-on-rails - Mechanize::响应代码错误:501

转载 作者:行者123 更新时间:2023-12-04 16:19:02 24 4
gpt4 key购买 nike

在 Ubuntu 上使用 Tor 并尝试代理 Mechanize

$ tor
Apr 15 11:40:10.024 [notice] Tor v0.2.4.21 (git-c5a648cc6f218339) running on Linux with Libevent 2.0.19-stable and OpenSSL 1.0.1c.
Apr 15 11:40:10.024 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Apr 15 11:40:10.024 [notice] Read configuration file "/etc/tor/torrc".
Apr 15 11:40:10.029 [notice] Opening Socks listener on 127.0.0.1:9050
Apr 15 11:40:10.029 [warn] Could not bind to 127.0.0.1:9050: Address already in use. Is Tor already running?
Apr 15 11:40:10.029 [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
Apr 15 11:40:10.029 [err] Reading config failed--see warnings above.

agent = Mechanize.new
agent.set_proxy('127.0.0.1', 9050)
agent.user_agent_alias = 'Mac Safari'
agent.get("http://www.linkedin.com/in/username")
=> Mechanize::ResponseCodeError: 501 => Net::HTTPNotImplemented for http://www.linkedin.com/in/username -- unhandled response
from /home/tristan/.rvm/gems/ruby-2.1.1/gems/mechanize-2.7.2/lib/mechanize/http/agent.rb:306:in `fetch'
from /home/tristan/.rvm/gems/ruby-2.1.1/gems/mechanize-2.7.2/lib/mechanize.rb:432:in `get'
from (irb):5
from /home/tristan/.rvm/gems/ruby-2.1.1/gems/railties-4.0.4/lib/rails/commands/console.rb:90:in `start'
from /home/tristan/.rvm/gems/ruby-2.1.1/gems/railties-4.0.4/lib/rails/commands/console.rb:9:in `start'
from /home/tristan/.rvm/gems/ruby-2.1.1/gems/railties-4.0.4/lib/rails/commands.rb:62:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

关于如何解决这个问题的任何想法?尝试代理这个真的很难!谢谢!

最佳答案

您在 mechanize 中设置的代理是 HTTP 代理,而不是 socks5 代理。 Tor 使用socks 代理而不是HTTP 代理。默认情况下,它会在端口 9050 上打开一个 socks 代理。

我建议你使用 privoxy这让您可以在端口 9050 上传递对 socks 代理的请求。

关于ruby-on-rails - Mechanize::响应代码错误:501,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23089788/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com