亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

GoColly 為每個請求設置代理

GoColly 為每個請求設置代理

Go
慕田峪4524236 2023-07-17 16:41:53
我開始對付科利。我正在嘗試為每個請求設置代理。但所有請求都不經過代理它應該有效 https://github.com/gocolly/colly/blob/master/request.go#L52我已將其添加到我的代碼中。但請求像以前一樣沒有代理c.OnRequest(func(r *colly.Request) {    r.ProxyURL = "..."    }也許我沒有正確理解它應該如何工作
查看完整描述

1 回答

?
qq_遁去的一_1

TA貢獻1725條經驗 獲得超8個贊

ProxyURL您是否嘗試過在收集器上設置它,而不是在回調函數中設置?


// SetProxy sets a proxy for the collector. This method overrides the previously

// used http.Transport if the type of the transport is not http.RoundTripper.

// The proxy type is determined by the URL scheme. "http"

// and "socks5" are supported. If the scheme is empty,

// "http" is assumed.

func (c *Collector) SetProxy(proxyURL string) error {

    proxyParsed, err := url.Parse(proxyURL)

    if err != nil {

        return err

    }


    c.SetProxyFunc(http.ProxyURL(proxyParsed))


    return nil

}


查看完整回答
反對 回復 2023-07-17
  • 1 回答
  • 0 關注
  • 191 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號