|
100精币
- Python实例
- import requests
- targetURL = "https://myip.top"
- proxyAddr = "您的代理IP:端口"
- authKey = "请改成您的Key"
- password = "请改成您的AuthPwd"
- # 账密模式
- proxyUrl = "http://%(user)s:%(password)s@%(server)s" % {
- "user": authKey,
- "password": password,
- "server": proxyAddr,
- }
- proxies = {
- "http": proxyUrl,
- "https": proxyUrl,
- }
- resp = requests.get(targetURL, proxies=proxies)
- print(resp.text)
GO语言 实例
- package main
- import (
- "fmt"
- "io/ioutil"
- "net/http"
- "net/url"
- )
- func main() {
- authKey := "请改成您的Key"
- password := "请改成您的AuthPwd"
- proxyServer := "您的代理IP:端口号"
- targetURL := "https://myip.top"
- rawURL := fmt.Sprintf("http://%s:%s@%s", authKey, password, proxyServer)
- proxyUrl, err := url.Parse(rawURL)
- if err != nil {
- panic(err)
- }
- client := http.Client{
- Transport: &http.Transport{
- Proxy: http.ProxyURL(proxyUrl),
- },
- }
- req, _ := http.NewRequest("GET", targetURL, nil)
- rsp, err := client.Do(req)
- if err != nil {
- fmt.Printf("request failed: %s\n", err)
- return
- }
- defer rsp.Body.Close()
- body, err := ioutil.ReadAll(rsp.Body)
- if err != nil {
- fmt.Println(err)
- } else {
- fmt.Println(string(body))
- }
- }
易语言怎么写?、
|
|