Пример #1
0
		def Get_qzone(self, model, pushitem, **kwargs):
				try:
						message = mail.EmailMessage()
						message.sender = '*****@*****.**' % pushitem.username
						message.to = '*****@*****.**' % pushitem.username
						message.body = htmllib.encoding(stringQ2B(htmllib.encoding(model.content)), 'gb18030')
						message.subject = htmllib.encoding(stringQ2B(htmllib.encoding(model.title)), 'gb18030')
						message.send()
						return self.Get_True(model, pushitem)
				except Exception, data:
						return self.Get_False(model, pushitem, data)
Пример #2
0
		def Get_msgs(self, model, pushitem, method, **kwargs):
				"""
				this method is used to get login to website,and put the content to the micro blog
				"""
				try:



					content = '#%s# %s 详细内容请查看:%s' % (htmllib.encoding(model.title, 'utf-8'),
								htmllib.encoding(htmllib.Filter_html(model.excerpt)[:70], 'utf-8'),
								htmllib.encoding(model.fullurl, 'utf-8'))
					#content=htmllib.encoding(content,'utf-8')
					memcachekey = method
					result = getattr(self, method)(pushitem.username, pushitem.password, content, memcachekey)
					if result:
						return self.Get_True(model, pushitem)
					else:
						return self.Get_False(model, pushitem)
				except Exception, data:
						return self.Get_False(model, pushitem, data)
Пример #3
0
		def Get_qzone2(self, model, pushitem, **kwargs):
				"""
				this method is used to get login to website,and put the content to the qzone
				"""
				try:


					contenthtml = u'%s 详细内容请查看:<a herf=%s>%s</a>' % (
								htmllib.decoding(htmllib.Filter_html(model.content)),
								unicode(model.fullurl), unicode(model.fullurl))
					contenthtml = htmllib.encoding(contenthtml, 'gb18030')
					title = htmllib.encoding(htmllib.decoding(model.title), 'gb18030')
					content = htmllib.Filter_html(contenthtml)
					#content=html
					result = self.send_qzone2(pushitem.username, pushitem.password, content, title, contenthtml)
					if result:
						return self.Get_True(model, pushitem)
					else:
						return self.Get_False(model, pushitem)
				except Exception, data:
						return self.Get_False(model, pushitem, data)
Пример #4
0
		def Get_blog163(self, model, pushitem, **kwargs):
			try:

				form_fields = {
						"title": htmllib.encoding(model.title, 'gb18030'),
						"content":htmllib.encoding(model.content, 'gb18030'),
						"name": pushitem.username,
						"password":pushitem.password
						}
				form_data = urllib.urlencode(form_fields)
				url = 'http://blog.163.com/common/targetgo.s'
				headers = {'Content-Type': 'application/x-www-form-urlencoded'}
				try:
					req = urllib2.Request(url, form_data, headers)
					result = urllib2.urlopen(req).read()
					print result
					return self.Get_True(model, pushitem)
				except URLError, e:
						logging.error('Push %s returned with %s.' % (pushitem.pushurl, e.reason))

			except Exception, data:
				print data
				return self.Get_False(model, pushitem, data)
Пример #5
0
		def send_qzone2(self, username, password, content, title, html):
			"""
			send qzone blog. use  username, password,content,title,html.
			the content parameter like html,but no html tag.
			"""
			memcachekey = 'send_qzone2'
			cookie = ''
			if cache.get(memcachekey):
				cookie = cache.get(memcachekey)
				logging.info('get cookie from memcache')
			else:
				result, oldcookie = self.Get_qzone2_val(username, password)
				cookie = '%s;%s' % (result.headers.get('set-cookie', ''), oldcookie)
				cache.set(memcachekey, cookie, 36000)
				logging.info('set cookie')
				
			tmphash = self.Tmp_skey_get(cookie)
			tmphash = self.myhash(tmphash)
			category = '个人日记'
			form_fields = {
				"uin":'939567050',
				"category":htmllib.encoding(category, 'gb18030'),
				"title":title,
				"content":content,
				"html":html,
				"cb_autograph":'1',
				"topflag":'0',
				"needfeed":'0',
				"lp_type":'0',
				"g_tk":tmphash,
				"scorr_20100723_":'http://qzs.qq.com/qzone/newblog/v5/editor.html|http://qzs.qq.com/qzone/newblog/v5/editor.html<http://user.qzone.qq.com/939567050/main',
			}
			form_data = urllib.urlencode(form_fields)
			try:
				result = urllib2.urlopen(url="http://b.qzone.qq.com/cgi-bin/blognew/blog_add",
								payload=form_data,
								method=urlfetch.POST,
								headers={'Referer':'http://imgcache.qq.com/qzone/v5/toolpages/fp_gbk.html',
								'Cookie' : cookie,
								'user-agent':'Mozilla/5.0 (Linux; U; Linux i686; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.4.2.80 Safari/525.13',

								}, follow_redirects=False)
			except Exception, data:
						logging.info(data)
						return False