pyquery示例-获取FreeBuf新闻标题

from pyquery import PyQuery as pq

d = pq(url="http://www.freebuf.com/")
alist = d(".newspic01")

print u"获取freebuf最新新闻的标题"
for node in range(len(alist)):
	print "%d.%s" %( node+1 , alist.eq(node)("a")("img").attr("title") )
'''
for node in range(len(alist)):
	print alist.eq(node)("a").attr("href")

for node in range(len(alist)):
	print alist.eq(node)("a")("img").attr("src")
'''

blist = d(".newspic01 a img")

print u"获取freebuf最新新闻的标题"
for node in range(len(blist)):
	print "%d.%s" %( node+1 , blist.eq(node).attr("title") )

你可能感兴趣的:(pyquery示例-获取FreeBuf新闻标题)