Python学习之Http
2012-06-10 21:39
232 查看
留下学习资料、方便自己和别人使用。
主要使用http.client 和 re 模块 进行网页数据的抓取和整理
主要使用http.client 和 re 模块 进行网页数据的抓取和整理
import http.client import re def RandomSong(): httpCon = http.client.HTTPConnection("music.sogou.com") httpCon.request("GET", "/sogou_phb/coo/music/getCampMeta2.jsp?cate=randomsong&count=100&&id=1&jsoncallback=jsonp1339165645104") response = httpCon.getresponse() data=response.read().decode('GBK') matchs= re.findall("(?=\"title\":\")[^\}]+", data) if matchs: for m in matchs: title=re.search("(?<=\"title\":\")[^\"]+", m) singer=re.search("(?<=\"singer\":\")[^\"]+", m) if title: str='title:'+title.group()+' singer:'+singer.group() print(str) else: print('not match') RandomSong()
相关文章推荐
- Python模块学习 ---- httplib HTTP协议客户端实现
- Python httplib学习
- 【Python】|廖雪峰官网学习笔记-HTTP简介
- Python模拟http协议初步学习(002)
- 【转】Python 第三方 http 库-Requests 学习
- 给大家推荐一个python的学习网站 http://www.codecademy.com
- python学习——aiohttp
- Python http访问学习
- Python 第三方 http 库-Requests 学习
- Python学习一、 Http协议客户端实现
- python2学习笔记之查看API接口、http的使用
- python httplib学习笔记
- Python模块学习 ---- httplib HTTP协议客户端实现
- Python爬虫学习(2): httplib
- Python 第三方 http 库-Requests 学习
- 转:Python模块学习 ---- httplib HTTP协议客户端实现
- Python 脚本学习(三),日志分析脚本,文件差异对比,HTTP状态检测
- Python模块学习 ---- httplib HTTP协议客户端实现
- Python3学习笔记(urllib模块的使用)转http://www.cnblogs.com/Lands-ljk/p/5447127.html
- Python模块学习 ---- httplib HTTP协议客户端实现