python爬虫入门到懵逼-2
来源:互联网 发布:软件著作权转让合同 编辑:程序博客网 时间:2024/05/22 13:29
用python2.7的urllib2 urllib发送POST请求提交表单
#--coding:utf-8--import urllib2import urlliburl="http://www.iqianyue.com/mypost" #带表单的网页postdata={"name":"zzxxss","pass":"90890809"}#表单数据 name passdata=urllib.urlencode(postdata).encode('utf-8')#用urllib.urlencode方法进行编码处理 用encode设置为UTF8req=urllib2.Request(url,data)#使用urllib2模块 创建request对象 参数url data#request对象添加user-agent模拟浏览器访问req.add_header('User-Agent',"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3141.7 Safari/537.36")#用urllib2的urlopen()方法向服务器发请求get_info=urllib2.urlopen(req).read()print get_info
阅读全文
0 0
- python爬虫入门到懵逼-2
- Python爬虫----爬虫入门(2)
- Python爬虫 | Python爬虫入门
- Python 爬虫入门 2 Phantomjs+Python
- python爬虫入门简单爬虫
- Python爬虫从入门到懵逼-0
- Python爬虫从入门到懵逼-1
- Python爬虫入门(2):爬虫基础了解
- Python爬虫入门(2):爬虫基础了解
- 菜鸟python入门爬虫手记(2)
- Python爬虫学习笔记(2):多线程入门
- Python爬虫入门2--请求(HTTP)
- Python爬虫入门
- Python爬虫入门
- Python爬虫入门基础
- 如何入门 Python 爬虫?
- python 爬虫入门
- 如何入门 Python 爬虫?
- Fibonacci非递归解法
- 背包模板讲解
- Android开发RecycleView的Item分割线
- [LeetCode]599. Minimum Index Sum of Two Lists
- [BZOJ4784][UOJ290][ZJOI017]仙人掌-树形DP
- python爬虫入门到懵逼-2
- java的初始化块
- TCP套接字编程
- WAV
- 计算机网络自顶向下 :应用层(DNS,POP)
- servlet和jsp学习(二)
- C/C++学习笔记二(变量、表达式)
- boost多个关键字索引multi_index_container
- LVS/DR模式工作原理的常见问题[转]