自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Python HTTP操作基本應(yīng)用方式簡(jiǎn)述

開(kāi)發(fā) 后端
Python HTTP操作在實(shí)際編程中是一個(gè)比較重要的操作技術(shù)。我們可以通過(guò)這里介紹的一些代碼片段來(lái)充分掌握這一應(yīng)用方式。

Python編程語(yǔ)言在實(shí)際應(yīng)用中給開(kāi)發(fā)人員帶來(lái)了非常大的好處。我們可以先通過(guò)這篇文章中介紹的有關(guān)Python HTTP操作的相關(guān)內(nèi)容對(duì)這一編程語(yǔ)言的應(yīng)用方式有一個(gè)詳細(xì)的了解,并增加對(duì)其的印象。

Python HTTP操作代碼示例:

  1. import urllib2,cookielib  
  2. class HTTPRefererProcessor(urllib2.BaseHandler):  
  3. def __init__(self):  
  4. self.referer = None   
  5. def http_request(self, request):  
  6. if ((self.referer is not None) and  
  7. not request.has_header("Referer")):  
  8. request.add_unredirected_header("Referer", self.referer)  
  9. return request   
  10. def http_response(self, request, response):  
  11. self.referer = response.geturl()  
  12. return response   
  13. https_request = http_request 
  14. https_response = http_response   
  15. cj = cookielib.CookieJar()  
  16. opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj),
     HTTPRefererProcessor(),)  
  17. urllib2.install_opener(opener)   
  18. data = 'msisdn=999999' 
  19. request = urllib2.Request(  
  20. url = 'http://203.117.16.171:8080/webgamecode/webcore?action=topup',  
  21. headers = {'Content-Type': 'application/x-www-form-urlencoded'},  
  22. datadata = data)  
  23. ret = opener.open(request)  
  24. content = ret.read()   
  25. print content  

以上就是我們對(duì)Python HTTP操作的相關(guān)介紹。

【編輯推薦】

  1. Python PAMIE模塊實(shí)現(xiàn)IE自動(dòng)化
  2. Python字符串顯示實(shí)際應(yīng)用技巧分享
  3. Python Socket編程實(shí)現(xiàn)網(wǎng)絡(luò)編程
  4. Python base64模塊基本概念總結(jié)
  5. Python取得文件列表基本應(yīng)用方式淺談
責(zé)任編輯:曹凱 來(lái)源: 博客園
相關(guān)推薦

2010-03-04 09:27:34

調(diào)用Python腳本

2010-03-03 14:30:05

Python set類

2010-03-03 14:40:37

Python打包方法

2010-03-03 10:03:55

Python連接Sql

2010-03-03 16:08:26

Python取得文件列

2010-03-03 15:17:46

Python調(diào)用MyS

2010-02-02 14:45:35

C++ typeof

2013-12-12 16:10:21

Lua腳本語(yǔ)言

2010-03-03 13:22:08

Python正則表達(dá)式

2010-01-25 13:45:04

Android單選框

2010-02-02 17:33:17

C++友元函數(shù)

2010-03-04 14:57:08

Python解密VBS

2010-07-08 15:24:17

SNMP trap

2010-03-05 15:47:59

Python Stri

2010-03-04 15:52:59

Python構(gòu)造列表

2010-02-04 17:16:33

C++調(diào)用python

2010-03-03 13:32:08

Python壓縮文件

2010-02-25 10:52:29

WCF響應(yīng)服務(wù)

2010-02-26 13:40:28

WCF消息頭

2010-02-25 18:04:02

WCF IIS宿主
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)