欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python大數(shù)據(jù)之網(wǎng)絡(luò)爬蟲的post請求、get請求區(qū)別實例分析

 更新時間:2019年11月16日 11:21:51   作者:xuehyunyu  
這篇文章主要介紹了Python大數(shù)據(jù)之網(wǎng)絡(luò)爬蟲的post請求、get請求區(qū)別,結(jié)合具體實例形式分析了Python網(wǎng)頁爬蟲post請求與get請求相關(guān)使用技巧,需要的朋友可以參考下

本文實例講述了Python大數(shù)據(jù)之網(wǎng)絡(luò)爬蟲的post請求、get請求區(qū)別。分享給大家供大家參考,具體如下:

在JetBrains PyCharm 2016.3軟件中編寫代碼前,需要指定python和編碼方式:

#!user/bin/python

編碼方式 :#coding=utf-8 或者 #-*-coding:utf-8-*-

post請求:

#導入工具,內(nèi)置的庫
import urllib
import urllib2
#加一個\可以換行
#response = \
  #urllib2.urlopen("https://hao.#/?wd_xp1")
#print response.read()
request = urllib2.Request('http://www.baidu.com')
#response = urllib2.urlopen(request)
#構(gòu)造post請求
params={}
params['account']='jredu'
params['pwd']=''
#對數(shù)據(jù)進行編碼
data = urllib.urlencode(params)
response = urllib2.urlopen(request,data)
print response.url
print response.code
print response.read()

get請求:

#導入工具,內(nèi)置的庫
import urllib
import urllib2
#加一個\可以換行
#response = \
  #urllib2.urlopen("https://hao.#/?wd_xp1")
#print response.read()
url='http://www.baidu.com'
#response = urllib2.urlopen(request)
#構(gòu)造post請求
params={}
params['account']='jredu'
params['pwd']=''
#對數(shù)據(jù)進行編碼
data = urllib.urlencode(params)
request = urllib2.Request(url+"?"+data)
response = urllib2.urlopen(request)
print response.url
print response.code
print response.read()

更多關(guān)于Python相關(guān)內(nèi)容可查看本站專題:《Python Socket編程技巧總結(jié)》、《Python正則表達式用法總結(jié)》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》、《Python入門與進階經(jīng)典教程》及《Python文件與目錄操作技巧匯總

希望本文所述對大家Python程序設(shè)計有所幫助。

相關(guān)文章

最新評論