Python爬虫中的Get和Post方法
来源:互联网 发布:c语言控制鼠标点击 编辑:程序博客网 时间:2024/05/01 11:06
通俗的说,Get是直接请求、打开,Post是请求、对方通过后才能打开。
Get和Post最重要的区别是,Get方式是直接一链接形式访问,链接中包含了所有的参数,当然如果包含了密码什么的是不安全的,不过你可以直观的看到自己提交的内容。
Post则不会再网址上显示所有参数,不过如果你想直接查看提交了什么就不太方便了。可以根据自己的需要酌情选择。
以下是典型的Post方式
import urllibimport urllib2url = "https://www.baidu.com/"value = {}value['username'] = 'Alice'value['password'] = '111'data = urllib.urlencode(value)req = urllib2.Request(url, data)response = urllib2.urlopen(req)print response.read()
以下是典型的Get方式
import urllibimport urllib2url = "https://www.baidu.com/"value = {}value['username'] = 'Alice'value['password'] = '111'data = urllib.urlencode(value)geturl = url + "?" + datareq = urllib2.Request(geturl)response = urllib2.urlopen(req)print response.read()
此处与上面的不同是有了个 geturl,它是把原来的 url 加 ? 加 编码后的参数。
所以会再网址上显示所有参数。
0 0
- Python爬虫中的Get和Post方法
- python爬虫get和post方法的使用以及cookie
- python爬虫笔记<一:POST和GET数据传送>
- Python的POST和GET方法
- python的get和post方法解析
- Form中的get和post方法
- http 中的post和get方法
- form中的get 和 post方法
- HTTP协议中的GET和POST方法
- jQuery中的get和post方法
- ajax中的get和post方法
- php表单中的get和post方法
- 代码中的post和get的方法
- get和post方法
- 关于Form中的post方法和get方法
- html中的get方法和post方法的区别
- Python3 爬虫--网页get和post
- flask和ajax中的post和get方法小结
- CSS清除浮动_清除float浮动
- 用 Python 编写网络爬虫 笔记
- Android之在linux环境不通过TAG快速过滤日志
- C实例---二维数组(指针实现)
- opencv之改变图像尺寸
- Python爬虫中的Get和Post方法
- Fragment + RadioGroup 实现类似于Tab的效果
- 并查集C++源码
- PAT 1011 A+B和C
- PHP检测文件方法,类方法是否存在
- directx初第七卷
- 算法提高 盾神与条状项链
- directx初第八卷
- 后面抽空看一下