摘要:
def remove_js_css (content): """ remove the the javascript and the stylesheet and the comment content ( and ) """ r = re.compile(r'''''',re.I|re.M|re.S) s = r.sub ('',content) r = re.compile(r'''''',re.I|re.M|re.S) 阅读全文
posted @ 2014-01-12 21:21
怒杀神
阅读(411)
评论(0)
推荐(0)
摘要:
#! /usr/bin/python# coding: utf-8from pyquery import PyQueryc=PyQuery('http://news.dbanotes.net/')titles=c.find('.title') for t in titles: title=c(t).find('a') t1=title('a').text() h1=title('a').attr('href') if t1!=None: print t1,'\n\t',h1 阅读全文
posted @ 2014-01-12 20:45
怒杀神
阅读(217)
评论(0)
推荐(0)
摘要:
In [25]: t= h('table')In [26]: In [26]: t('.mainbox').text()Out[26]: u'\u72b6\u6001 \u4e3b\u9898 \u4f5c\u8005 \u56de\u590d / \u4eba\u6c14 \u6700\u540e\u66f4\u65b0 \u663e\u793a\u56fa\u9876\u4e3b\u9898\u5f00\u59cb \u633a\u62d4\u76f4\u901a\u5fb7\u56fd\u9009\u62d4\u8d5b \u7530\u603b\ 阅读全文
posted @ 2014-01-12 19:49
怒杀神
阅读(2224)
评论(0)
推荐(0)
摘要:
目标地址:http://www.espncricinfo.com/champions-league-twenty20-2012/engine/match/574265.htmlliz@nb-liz:~$ script pyquery.log2Script started, file is pyquery.log2liz@nb-liz:~$ ipythonPython 2.7.3 (default, Jan 2 2013, 16:53:07) Type "copyright", "credits" or "license" for mo 阅读全文
posted @ 2014-01-12 17:26
怒杀神
阅读(418)
评论(0)
推荐(0)
摘要:
pyquery库是jQuery的Python实现,可以用于解析HTML网页内容,官方文档地址是:http://packages.python.org/pyquery/。二、使用方法?1from pyquery import PyQuery as pq可加载一段HTML字符串,或一个HTML文件,或是一个url地址,例:?123d=pq("hello")d=pq(filename=path_to_html_file)d=pq(url='http://www.baidu.com')注意:此处url似乎必须写全html()和text() ——获取相应的HTML块或 阅读全文
posted @ 2014-01-12 16:37
怒杀神
阅读(623)
评论(0)
推荐(0)
摘要:
pyQuerypyQuery是 jQuery 在 python 中的实现,能够以 jQuery 的语法来操作解析 HTML 文档,十分方便。使用前需要安装,easy_install pyquery 即可,或者 Ubuntu 下sudo apt-get install python-pyquery以下例子:from pyquery import PyQuery as pyqdoc=pyq(url=r'http://list.taobao.com/browse/cat-0.htm')cts=doc('.market-cat')for i in cts: print 阅读全文
posted @ 2014-01-12 15:33
怒杀神
阅读(474)
评论(0)
推荐(0)

浙公网安备 33010602011771号