requests.exceptions.ConnectionError:无法建立新连接:0x05:连接被拒绝

时间:2019-08-22 20:30:36

标签: python python-requests mechanize-python

我知道已经有很多关于该主题的主题,但是没有一个主题可以吸引我。

import mechanicalsoup

browser = mechanicalsoup.StatefulBrowser()
browser.set_user_agent(
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36')

proxies = dict(http='socks5://104.238.97.230:31800', https='socks5://104.238.97.230:31800')
res = browser.open('http://icanhazip.com/', proxies=proxies, verify=False)
# res = browser.open('http://icanhazip.com/')
print(res.content)

我的代理正在工作,没有问题。如果我通过proxifier重定向python流量,则会得到想要查看的结果,但是如果我只是尝试这段代码,则会收到错误消息。

我也尝试过尝试-除了睡觉,但这对我没有用。有人知道解决方案吗?

1 个答案:

答案 0 :(得分:0)

这对我有用:

[DesignTimeVisible(false)]
public partial class MainPage : ContentPage
{

    public MainPage()
    {
        InitializeComponent();
    }

    private void NumericalAxis_ActualRangeChanged(object sender, ActualRangeChangedEventArgs e)
    {
        e.ActualMinimum = AxisMinimum;
    }
}


public class SaleInfo
{
    public string date { get; set; }
    public string minute { get; set; }
    public string label { get; set; }
    public double high { get; set; }
    public double low { get; set; }
    public double open { get; set; }
    public double close { get; set; }
    public double average { get; set; }
    public int volume { get; set; }
    public double notional { get; set; }
    public int numberOfTrades { get; set; }
}

public class SalesViewModel
{
    public List<SaleInfo> SalesData { get; set; }

    public SalesViewModel()
    {
        SalesData = new List<SaleInfo>();

        SalesData.Add(new SaleInfo { date = "2019-08-16", minute = "09:30", label = "09:30 AM", high = 204.84, low = 204.05, open = 204.3, close = 904.75, average = 204.508, volume = 8709, notional = 1781061.51, numberOfTrades = 69 });
        SalesData.Add(new SaleInfo { date = "2019-08-16", minute = "09:31", label = "09:31 AM", high = 204.8, low = 204.46, open = 204.8, close = 904.5, average = 204.622, volume = 5783, notional = 1183329.75, numberOfTrades = 58 });
        SalesData.Add(new SaleInfo { date = "2019-08-16", minute = "09:32", label = "09:32 AM", high = 204.72, low = 204.34, open = 204.46, close = 904.36, average = 204.548, volume = 4468, notional = 913920.6, numberOfTrades = 50 });
        SalesData.Add(new SaleInfo { date = "2019-08-16", minute = "09:33", label = "09:33 AM", high = 204.41, low = 204.06, open = 204.39, close = 904.06, average = 204.243, volume = 1834, notional = 374581.99, numberOfTrades = 22 });

        double AxisMinimum = SalesData.Min(SaleInfo => SaleInfo.close);
    }
}