通过SOCKS协议的HTTP请求

时间:2019-01-18 12:01:21

标签: java http proxy http-proxy socks

我正在尝试使用Socks 5 代理进行http发布请求。代理的提供者已禁用http或其他内容。 我收到以下错误;

Exception in thread "main" java.net.SocketException: SOCKS: Connection not allowed by ruleset

我正在使用代码

    System.setProperty("java.net.socks.username", user);
    System.setProperty("java.net.socks.password", pass);

    Proxy prox = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(ip, 8000));
    URL url = new URL("https://www.myip.com");
    URLConnection con = url.openConnection(prox);

    con.setConnectTimeout(10000);
    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));

    String line;
    while ((line = in.readLine()) != null) {
        System.out.println(line);
    }
    in.close();

我如何通过代理隧道(?)此http请求?

PS我知道这是可能的,因为firefox中的某些扩展允许我也使用代理 我也尝试过此代码,但会导致相同的错误:https://pastebin.com/xt6evbm7

1 个答案:

答案 0 :(得分:0)

此系统不使用系统属性。

new_df = pd.DataFrame()

for x, y  in df.groupby(['cust', 'group']):
    resampled=y.set_index('date').resample('D').val.mean().to_frame().rename({'val': 'resamp_val'}, axis=1) 
    resampled = resampled.join(y.set_index('date')).fillna({'cust':x[0],'group':x[1]})
    resampled['resamp_val_pct'] = resampled.resamp_val.pct_change(fill_method=None)

    new_df = pd.concat([new_df, resampled])

new_df = new_df[['cust', 'group', 'val', 'resamp_val', 'resamp_val_pct']]
new_df
相关问题