這段代碼要怎么進(jìn)行修改?-創(chuàng)新互聯(lián)

requests

專注于為中小企業(yè)提供成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)應(yīng)城免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了成百上千企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
        #! -*- encoding:utf-8 -*-
        import requests
        import random
        # 要訪問(wèn)的目標(biāo)頁(yè)面
        targetUrl = "http://httpbin.org/ip"
        # 要訪問(wèn)的目標(biāo)HTTPS頁(yè)面
        # targetUrl = "https://httpbin.org/ip"
        # 代理服務(wù)器
        proxyHost = "t.16yun.cn"
        proxyPort = "31111"
        # 代理隧道驗(yàn)證信息
        proxyUser = "username"
        proxyPass = "password"
        proxyMeta = "http://%(user)s:%(pass)s@%(host)s:%(port)s" % {
            "host" : proxyHost,
            "port" : proxyPort,
            "user" : proxyUser,
            "pass" : proxyPass,
        }
        # 設(shè)置 http和https訪問(wèn)都是用HTTP代理
        proxies = {
            "http"  : proxyMeta,
            "https" : proxyMeta,
        }
        #  設(shè)置IP切換頭
        tunnel = random.randint(1,10000)
        headers = {"Proxy-Tunnel": str(tunnel)}
        resp = requests.get(targetUrl, proxies=proxies, headers=headers)
        print resp.status_code
        print resp.text

當(dāng)前名稱:這段代碼要怎么進(jìn)行修改?-創(chuàng)新互聯(lián)
網(wǎng)站地址:http://muchs.cn/article2/spjoc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站維護(hù)、外貿(mào)建站、網(wǎng)站收錄、App設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名