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

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

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

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

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

#!user/bin/python

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

post請(qǐng)求:

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

get請(qǐng)求:

#導(dǎo)入工具,內(nèi)置的庫(kù)
import urllib
import urllib2
#加一個(gè)\可以換行
#response = \
  #urllib2.urlopen("https://hao.#/?wd_xp1")
#print response.read()
url='http://www.baidu.com'
#response = urllib2.urlopen(request)
#構(gòu)造post請(qǐng)求
params={}
params['account']='jredu'
params['pwd']=''
#對(duì)數(shù)據(jù)進(jìn)行編碼
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正則表達(dá)式用法總結(jié)》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》、《Python入門(mén)與進(jìn)階經(jīng)典教程》及《Python文件與目錄操作技巧匯總

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

相關(guān)文章

最新評(píng)論