新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
Python HTTP操作基本應(yīng)用方式簡(jiǎn)述
Python編程語(yǔ)言在實(shí)際應(yīng)用中給開發(fā)人員帶來(lái)了非常大的好處。我們可以先通過(guò)這篇文章中介紹的有關(guān)Python HTTP操作的相關(guān)內(nèi)容對(duì)這一編程語(yǔ)言的應(yīng)用方式有一個(gè)詳細(xì)的了解,并增加對(duì)其的印象。

在剛察等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場(chǎng)前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè) 網(wǎng)站設(shè)計(jì)制作定制網(wǎng)站建設(shè),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),高端網(wǎng)站設(shè)計(jì),成都全網(wǎng)營(yíng)銷,成都外貿(mào)網(wǎng)站制作,剛察網(wǎng)站建設(shè)費(fèi)用合理。
Python HTTP操作代碼示例:
- import urllib2,cookielib
- class HTTPRefererProcessor(urllib2.BaseHandler):
- def __init__(self):
- self.referer = None
- def http_request(self, request):
- if ((self.referer is not None) and
- not request.has_header("Referer")):
- request.add_unredirected_header("Referer", self.referer)
- return request
- def http_response(self, request, response):
- self.referer = response.geturl()
- return response
- https_request = http_request
- https_response = http_response
- cj = cookielib.CookieJar()
- opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj),
HTTPRefererProcessor(),)- urllib2.install_opener(opener)
- data = 'msisdn=999999'
- request = urllib2.Request(
- url = 'http://203.117.16.171:8080/webgamecode/webcore?action=topup',
- headers = {'Content-Type': 'application/x-www-form-urlencoded'},
- datadata = data)
- ret = opener.open(request)
- content = ret.read()
- print content
以上就是我們對(duì)Python HTTP操作的相關(guān)介紹。
【編輯推薦】
- Python PAMIE模塊實(shí)現(xiàn)IE自動(dòng)化
- Python字符串顯示實(shí)際應(yīng)用技巧分享
- Python Socket編程實(shí)現(xiàn)網(wǎng)絡(luò)編程
- Python base64模塊基本概念總結(jié)
- Python取得文件列表基本應(yīng)用方式淺談
文章標(biāo)題:Python HTTP操作基本應(yīng)用方式簡(jiǎn)述
分享URL:http://fisionsoft.com.cn/article/dppipho.html


咨詢
建站咨詢
