国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > Python > 正文

Python大數據之網絡爬蟲的post請求、get請求區別實例分析

2024-09-09 19:02:28
字體:
來源:轉載
供稿:網友

本文實例講述了Python大數據之網絡爬蟲的post請求、get請求區別。分享給大家供大家參考,具體如下:

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

#!user/bin/python

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

post請求:

#導入工具,內置的庫import urllibimport urllib2#加一個/可以換行#response = /  #urllib2.urlopen("https://hao.360.cn/?wd_xp1")#print response.read()request = urllib2.Request('http://www.baidu.com')#response = urllib2.urlopen(request)#構造post請求params={}params['account']='jredu'params['pwd']=''#對數據進行編碼data = urllib.urlencode(params)response = urllib2.urlopen(request,data)print response.urlprint response.codeprint response.read()

get請求:

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

更多關于Python相關內容可查看本站專題:《Python Socket編程技巧總結》、《Python正則表達式用法總結》、《Python數據結構與算法教程》、《Python函數使用技巧總結》、《Python字符串操作技巧匯總》、《Python入門與進階經典教程》及《Python文件與目錄操作技巧匯總》

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 和平区| 大连市| 泉州市| 县级市| 吉安县| 治县。| 融水| 鲁山县| 搜索| 合江县| 新竹市| 赤城县| 凉城县| 手机| 平昌县| 平原县| 沙田区| 布尔津县| 紫阳县| 黄石市| 长武县| 夹江县| 南投市| 耒阳市| 静宁县| 农安县| 靖西县| 武隆县| 喀喇| 台南市| 新沂市| 浦东新区| 广丰县| 延津县| 东至县| 屏东市| 竹北市| 大关县| 邮箱| 德钦县| 荔波县|