我正在尝试使用库HTTParty
,但每当我运行下面的代码时,我都会收到错误。
码:
require 'httparty'
response = HTTParty.get('http://example.com')
当我运行代码时,我收到错误:Errno::ECONNREFUSED (Failed to open TCP connection to :80 (Connection refused - connect(2) for nil port 80))
。当我在net/http
中运行相同的代码时,我没有收到任何错误。我不知道这是否有帮助,但我运行的系统是Linux Mint 18.3 Cinnamon 64-bit。
我知道这已经晚了,但使用https://example.com
而不是http://example.com
是解决我的问题的方法。