<a href=http://developer.51cto.com/art/201705/"link2.html">second item</a> <a href=http://developer.51cto.com/art/201705/"link3.html"><span class="bold">third item</span></a> <a href=http://developer.51cto.com/art/201705/"link4.html">fourth item</a> <a href=http://developer.51cto.com/art/201705/"link5.html">fifth item</a> <li class="item-0">first item</li> <li class="item-1"><a href=http://developer.51cto.com/art/201705/"link2.html">second item</a></li> <li class="item-0 active"><a href=http://developer.51cto.com/art/201705/"link3.html"><span class="bold">third item</span></a></li> <li class="item-1 active"><a href=http://developer.51cto.com/art/201705/"link4.html">fourth item</a></li> <li class="item-0"><a href=http://developer.51cto.com/art/201705/"link5.html">fifth item</a></li> 不过最常用的┞氛样 items 办法
网页请求
PyQuery 本身还有网页请求功能,并且会把请求下来的网页代码转为 PyQuery 对象。
- from pyquery import PyQuery as pq
-
- print pq('http://cuiqingcai.com/', headers={'user-agent': 'pyquery'})
-
- print pq('http://httpbin.org/post', {'foo': 'bar'}, method='post', verify=True)
感触感染一下,GET,POST,样样通。
Ajax
PyQuery 同样支撑 Ajax 操作,带有 get 和 post 办法,不过不常用,一般我们不会用 PyQuery 来做收集请求,仅仅是用来解析。
PyQueryAjax
API
最后少不了的,API大年夜放送。
API (https://pythonhosted.org/pyquery/api.html)
原汁原味最全的API,都在琅绫擎了!如不雅你对 jQuery 语法不熟,强烈建议先进修下 jQuery,再回来看 PyQuery,你会认为异常亲切!
然而比比 PyQuery,哦我的确太爱它了!
结语
用完了 PyQuery,我已经深深爱上了他!
你呢?
【编辑推荐】
- Python爬虫爬取知乎小结
- 深刻Python列表的内部实现
- 应用Python供给高机能计算办事
- 深刻懂得GIL:若何写出高机能及线程安然的Python代码
- Python算法拭魅战系列:栈
【义务编辑:枯木 TEL:(010)68476606】
推荐阅读
OTT IPTV商机广阔 运营商如何进一步发掘CDN机会窗口
在此前4月份的亚太CDN峰会上,中国联通收集技巧研究院、高等工程师乔治曾做过一个猜测:全球流量复合增长率占>>>详细阅读
本文标题:Python爬虫神器PyQuery的使用方法
地址:http://www.17bianji.com/lsqh/35490.html
1/2 1