python网络爬虫(一)
来源:互联网 发布:淘宝抢购秒杀器手机版 编辑:程序博客网 时间:2024/04/24 21:07
POST方式
from urllib.error import URLError,HTTPError
import urllib.requestimport urllib.parse
url='http://www.baidu.com/s'
values={'wd':'python',
'opt-webpage':'on',
'ie':'gbk'}
data=urllib.parse.urlencode(values).encode(encoding='utf_8')
req=urllib.request.Request(url,data)
#or ony one sentense:full_url=url+'?'+url_values
try:
response=urllib.request.urlopen(req)
except HTTPError as e:
print('Error code:',e.code)
except URLError as e:
print('Reason',e.reason)
the_page=response.read()
print(the_page)
GET方式
import urllib.request
import urllib.parse
values={"rls":"ig"}
data= urllib.parse.urlencode(values)
url = 'http://www.baidu.com'
full_url = url + '?' + data
req=urllib.request.Request(full_url )
response = urllib.request.urlopen(req)
page=response.read()
print( page)
0 0
- 【网络爬虫】【python】网络爬虫(一):python爬虫概述
- python网络爬虫(一)
- python网络爬虫(一)
- python网络爬虫(一)
- 写网络爬虫学python(一)
- python 网络爬虫(一) 简单demo
- 【Python】网络爬虫(一):pyquery一瞥
- [Python]网络爬虫(一):一些基本概念
- 学习python写网络爬虫(一)
- 学习Python之网络爬虫(一)
- Python 网络爬虫学习(一)
- python网络爬虫实战笔记(一)
- Python网络爬虫(一):初步了解
- Python网络爬虫学习笔记(一)
- 【python网络爬虫一】爬虫工作原理
- Python之网络爬虫一
- Python实战(一)——Python编写网络爬虫
- Python 网络爬虫与信息获取(一)—— requests 库的网络爬虫
- XMPP文件传输(XEP-0096协议说明)
- android的低内存管理器
- Android4.4之Keyguard--KeyguardMessageArea
- 剑指offer:将字符串转化为整形
- 浏览器探究——webkit部分——WebKit平台相关层基本架构
- python网络爬虫(一)
- 常见Android屏幕分辨率以及对应机型
- asp.net中计算文件夹的大小
- 《程序员面试宝典-第四版》之递归学习
- Vc串口通信(1)
- python根据unicode判断语言类型
- SVN提交代码出现403 Forbidden的错误
- [Unity3D]Script 脚本所有编译器属性详解
- 浏览器探究——Framework层基本架构