今天母亲节,写了个程序。抓取一个站点的母亲节祝福短信。实现自己主动翻页,

道友们也能够甲乙改造。比方加上节日简洁,time()模块。

一起分享吧


# -*- coding: cp936 -*-
#http://www.aizhufu.cn/duanxinku/column/89/1.html
import urllib


k=0
while k<15:             #页数
    k+=1
    url = "http://www.aizhufu.cn/duanxinku/column/89/"+str(k)+".html"
    con = urllib.urlopen(url,'r')
    content=con.read()

    w2 = content.find("w2 readContent")
    nextw2 = content.find("w2 readContent",w2)
    i=0                     #每页短语条数

    while w2 != -1 and nextw2 != -1 and i<11:
        w2 = content.find("w2 readContent",nextw2)
        nextw2 = content.find("w2 readContent",w2+6)
        sentence=content[w2 +31:w2+600]
        sentence = sentence[1:sentence.find("'",2)]
        i+=1
        print sentence


相关文章:

  • 2021-09-13
  • 2021-06-06
  • 2021-06-14
  • 2021-12-26
  • 2022-02-17
  • 2021-07-29
  • 2021-10-12
猜你喜欢
  • 2022-01-03
  • 2021-08-25
  • 2021-09-29
  • 2021-11-19
  • 2022-12-23
  • 2021-08-24
  • 2021-09-18
相关资源
相似解决方案