码迷,mamicode.com
首页 > 编程语言 > 详细

Python requests

时间:2014-09-19 19:05:45      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:http   io   os   ar   sp   cti   on   c   html   

一个最简化的例子

payload = {‘wd‘: ‘google‘, ‘rn‘: ‘100‘}
r = requests.get("http://www.baidu.com/s", params=payload)
print r.url
u‘http://www.baidu.com/s?rn=100&wd=google‘

 

更多参考:http://cn.python-requests.org/en/latest/

https://docs.python.org/2/library/simplehttpserver.html?highlight=requests

http://www.zhidaow.com/post/python-requests-install-and-brief-introduction

 

百度网页中www.baidu.com/s?的说明:

这是HTTP的GET方法。HTTP常用的在不同页面传值的有GET和POST两种方法。
其中GET在传值时会把值显示在地址栏,以问号来标示,问号后面就是传的值了。
比如你在百度搜索栏填个“99”,这时它的地址栏显示:http://www.baidu.com/s?wd=99&cl=3
意思是给wd传了个99的值,cl传了个3的值,至于wd和cl代表什么意思,只有写这个页面的程序员知道了。
s是页面名。
但这样有时有危险,比如你输的是帐号密码什么的,也能在地址栏看见,那还了得!!!
于是有两种处理方法:1.把你输入的转为乱码 2.用POST方法

 

Python requests

标签:http   io   os   ar   sp   cti   on   c   html   

原文地址:http://www.cnblogs.com/haochuang/p/3981885.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!