获取博客园首页的博客列表,获取博客首页,#! /usr/bin/


#! /usr/bin/env python#coding:gbk"""获取博客园首页的博客列表"""from pyquery import PyQuery as pqfor p in range(1,2):    print "正在获取第",p,"页"    doc=pq(url=r'http://www.cnblogs.com/p'+str(p))    a=doc(".post_item")    f=open("c:\\\\cnbloglist.txt","a")    for i in a:        try:            print pq(i).find("h3").text() ,pq(i).find(".post_item_foot").text()            #, pq(i).find("span.article_comment").text() , pq(i).find("span.article_view").text()                       f.write(pq(i).find("h3").text().encode("gbk")+"\\n")        except:            pass          f.close()#该片段来自于http://byrx.net

评论关闭