修正版的自动转发脚本
把登录封装到login.py里面了,别的没变。主要是那句sss=str(sss)救命了…………
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# coding=utf-8 import urllib import urllib2 import cookielib import sys import poststatus import time import login from StringIO import StringIO def zhuanfa(): html=login.login() index=html.find('转自') #print html while index>=0: html=html[index:] index2=html.find('<p') sss=html[:index2] html=html[index2:] fw=open('zhuanfa.db','a') fr=open('zhuanfa.db','r') alllines=fr.readlines() #print sss sss=str(sss) fr.close() boo=1 for each in alllines: if sss.find(each[len(each)/2:len(each)/3*2])>0: boo=0 if boo==1: poststatus.zhuangtai('自动转发:'+sss) fw.write('n'+sss+'n') print 'n已存'+sss else: pass #print '发现转发过的状态' index=html.find('转自') |
本文出自 杨肉的演讲台,转载时请注明出处及相应链接。
本文永久链接: https://yangzhe1991.org/blog/2010/11/%e4%bf%ae%e6%ad%a3%e7%89%88%e7%9a%84%e8%87%aa%e5%8a%a8%e8%bd%ac%e5%8f%91%e8%84%9a%e6%9c%ac/