def get(self): textnum=98 addsubject=u'#趣图##搞笑##笑话#' jmark=PutWeibMark.get_by_key_name('mark') jlist=Joke.all() if jmark: joke=Joke.get_by_key_name(jmark.jokename) else: joke=None jmark=PutWeibMark(key_name='mark') if joke: jlist.filter('updateTime >',joke.updateTime) jlist.filter('type =',2).order('updateTime').fetch(1) jlist.order('updateTime').fetch(1) try: j=jlist[0] jmark.jokename=j.key().name() jmark.put() j.joke=html_parser.unescape(j.joke.replace(u'绿',u'转')) j.put() j.joke=j.joke.replace('<br/>','') total=len(j.joke)/textnum if len(j.joke)%textnum>0: total=int(total)+1 m=1 mark='' if j.img: image = urlfetch.fetch( url =j.img, payload = {}, method = urlfetch.GET, headers = {'Content-Type':'application/x-www-form-urlencoded', 'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6'}, follow_redirects = True,deadline=10) if image.status_code==200: bf=db.Blob(image.content) if total>=m and total>1: mark='(%s/%s)'%(m,total) m+=1 sendWeibo(self,addsubject+j.joke[:textnum]+mark+'http://www.123fangsong.com/%s.html'%jmark.jokename,bf) j.joke=j.joke[textnum:] while j.joke: if total>=m and total>1: mark='(%s/%s)'%(m,total) m+=1 sendWeibo(self,'http://www.123fangsong.com/%s.html'%jmark.jokename+' '+j.joke[:textnum]+mark+addsubject) j.joke=j.joke[textnum:] except Exception,e: logging.info('empty'+str(e))
def get(self): for j in HtmlPage.all().fetch(): j.delete() for j in Joke.all().fetch(200): j.delete()