예제 #1
0
def getBots(accounts):
    bots = []
    for account in accounts:
        bot = RenRen()
        bot.login(account[0], account[1])
        print bot.email, 'login'
        bots.append(bot)
    return bots
예제 #2
0
def getBots(accounts):
    bots = []
    for account in accounts:
        bot = RenRen()
        bot.login(account[0], account[1])
        print bot.email, 'login'
        bots.append(bot)
    return bots
예제 #3
0
 def __init__(self):
     ''' use tornaod LogFormatter '''
     self._news_url_template = string.Template(
         SITE_URL + "/index.php/News/student/p/$p/")
     self._init_going = False
     self.renren = RenRen()
     self.renren.login(config.renren_email, config.renren_pw)  # login
     self.post_queue = []  # this is a heapq of new's id
예제 #4
0
 def __init__(self):
     ''' use tornaod LogFormatter '''
     self._news_url_template = string.Template(
         SITE_URL+"/index.php/News/student/p/$p/")
     self._init_going = False
     self.renren = RenRen()
     self.renren.login(config.renren_email, config.renren_pw)  # login
     self.post_queue = []  # this is a heapq of new's id
예제 #5
0
def getBots(accounts):
    if 'main.py' in sys.argv[0]:
        bots = []
        for account in accounts:
            bot = RenRen()
            bot.login(account[0], account[1])
            print bot.email, 'login'
            bots.append(bot)
        return bots
    else:
        r = redis.Redis(REDIS_HOST)
        bot = RenRen()
        bot._loginByCookie(r.get('xiaohuangji_cookies'))
        bot.email = ''
        if bot.token:
            return [bot]
        else:
            return []
예제 #6
0
def getBots(accounts):
    if 'main.py' in sys.argv[0]:
        bots = []
        for account in accounts:
            bot = RenRen()
            bot.login(account[0], account[1])
            print bot.email, 'login'
            bots.append(bot)
        return bots
    else:
        r = redis.Redis(REDIS_HOST)
        cookies = r.get('xiaohuangji_cookies')
        bot = RenRen()
        if cookies:
            bot._loginByCookie(cookies)
            bot.email = ''
        else:
            account = accounts[0]
            bot.login(account[0], account[1])
        return [bot] if bot.token else []
예제 #7
0
class SSdutSiteCrawler(object):
    def __init__(self):
        ''' use tornaod LogFormatter '''
        self._news_url_template = string.Template(
            SITE_URL+"/index.php/News/student/p/$p/")
        self._init_going = False
        self.renren = RenRen()
        self.renren.login(config.renren_email, config.renren_pw)  # login
        self.post_queue = []  # this is a heapq of new's id

    def page_url(self, p):
        url = self._news_url_template.substitute(p=p)
        logging.debug("page url = %r" % url)
        return url

    def get_page_result(self, p):
        src = urlopen(self.page_url(p)).read()
        return par.ssdut_news_list(src)

    def add_new_post_to_q(self, id):
        heapq.heappush(self.post_queue, id)
        print self.post_queue

    def do_one_post_in_q(self):
        self.renren.visit(514178406)
        try:
            id = heapq.heappop(self.post_queue)
        except IndexError:  # empty queue
            return
        # really post
        try:
            new = New.query.filter(New.id == id).one()
            db.ses.commit()
            s = ''.join([
                new.title,
                ' - ',
                new.publisher,
                ' ',
                'http://ssdut.dlut.edu.cn',
                new.link])
            if True:
                s = s + " 想吐槽? -> http://210.30.97.149:2358/tucao/comm/%d" % int(new.id)
            self.renren.postStatus(s)
            logging.info("POST ON RENREN: %s" % s)
        except Exception, e:
            self.add_new_post_to_q(id)  # maybe next time it could be posted
            db.ses.rollback()
            traceback.print_exc()
예제 #8
0
class SSdutSiteCrawler(object):
    def __init__(self):
        ''' use tornaod LogFormatter '''
        self._news_url_template = string.Template(
            SITE_URL + "/index.php/News/student/p/$p/")
        self._init_going = False
        self.renren = RenRen()
        self.renren.login(config.renren_email, config.renren_pw)  # login
        self.post_queue = []  # this is a heapq of new's id

    def page_url(self, p):
        url = self._news_url_template.substitute(p=p)
        logging.debug("page url = %r" % url)
        return url

    def get_page_result(self, p):
        src = urlopen(self.page_url(p)).read()
        return par.ssdut_news_list(src)

    def add_new_post_to_q(self, id):
        heapq.heappush(self.post_queue, id)
        print self.post_queue

    def do_one_post_in_q(self):
        self.renren.visit(514178406)
        try:
            id = heapq.heappop(self.post_queue)
        except IndexError:  # empty queue
            return
        # really post
        try:
            new = New.query.filter(New.id == id).one()
            db.ses.commit()
            s = ''.join([
                new.title, ' - ', new.publisher, ' ',
                'http://ssdut.dlut.edu.cn', new.link
            ])
            if True:
                s = s + " 想吐槽? -> http://210.30.97.149:2358/tucao/comm/%d" % int(
                    new.id)
            self.renren.postStatus(s)
            logging.info("POST ON RENREN: %s" % s)
        except Exception, e:
            self.add_new_post_to_q(id)  # maybe next time it could be posted
            db.ses.rollback()
            traceback.print_exc()
예제 #9
0
# 主动聊天

import sys
sys.path.append('..')

import random
from redis import Redis
from renren import RenRen
from my_accounts import accounts
import time
from crawl_info_config import crawl_info_list

kv = Redis(host='localhost')
account = accounts[0]
bot = RenRen(account[0], account[1])


def handle(keyword, responses):
    statuses = bot.searchStatus(keyword, max_length=10)
    for status in statuses:
        user_id, status_id, status_time = status
        status_id_hash = int(str(status_id)[1:])
        if not kv.getbit('status_record', status_id_hash):
            print keyword, user_id, status_id, status_time
            bot.addComment({
                'type': 'status',
                'source_id': status_id,
                'owner_id': user_id,
                'message': random.choice(responses)
            })
예제 #10
0
# -*- coding=UTF-8 -*-
from renren import RenRen

if __name__ == "__main__":
    text = "测试"

    r = RenRen()
    r.postStatus(text)
예제 #11
0
# -*- coding: utf-8 -*-

from renren import RenRen
from selenium import webdriver # parse dynamic web pages
import time

email = "XXXXXXXXXXXXXXX"
passwd = 'XXXXXXXXXXXXXXX'
renren = RenRen(email, passwd)
# import pdb;pdb.set_trace()
# friends_list = renren.get_friends()

driver = webdriver.Firefox() # assume you have firefox on your local computer
# login first
driver.get('http://renren.com')
username = driver.find_element_by_id("email")
password = driver.find_element_by_id("password")
username.send_keys(email)
password.send_keys(passwd)
driver.find_element_by_id("login").click()
time.sleep(5)
# import pdb;pdb.set_trace()
print renren.search_profiles('name', 20, driver)
driver.close()
예제 #12
0
#!/usr/bin/env python
#-*- coding: utf-8 -*-

from renren import RenRen

renren = RenRen()
renren.login("*****@*****.**", "pedestaldlut")

s = "ceshi"
print renren.postStatus(s)['msg']
예제 #13
0
파일: web.py 프로젝트: ccp0101/confessions
def getBot():
    renren = RenRen()
    renren.login(os.environ["RENREN_USERNAME"], os.environ["RENREN_PASSWORD"])
    renren.switchAccount("2020816463")
    return renren
예제 #14
0
파일: main.py 프로젝트: jackyyf/RenRenRP
import time
from renren import RenRen
import logger

RPIntervalBefore	= '<input type="hidden" id="interval" value=\''
RPIntervalAfter		= '\'/>'
RPAmountBefore		= '<input type="hidden" id="refreshRp" value=\''
RPAmountAfter		= '\'/>'

if __name__ == '__main__':

	print 'If you have any problem, please open an issue at https://github.com/jackyyf/RenRenRP'

	# print 'RenRen Refresh Daemon, PID = %d' % os.getpid()

	renren = RenRen()

	try:
		while True:
			if not renren.console_login():
				continue
			while True:
				try:
					content = renren.RPRefresh()
				except KeyboardInterrupt:
					raise
				except:
					logger.stackTrace()
					print 'Error! Login Again...'
					break
				pos = content.find(RPIntervalBefore)
예제 #15
0
# -*-coding:utf-8-*-
'''
Created on 2013-5-21

@author: mush
'''
from ntype import NTYPES
import re
from renren import RenRen

# 匹配自己名字的正则@CityRun(601414776)
self_match_pattern = re.compile('@烟台高校信息发布平台(\(601742726\))?')

bot = RenRen()


# 从一条消息里取出要表白的对象和要说的话
# 内容格式因为“@CityRun(601414776) 我想跟牟俊秋(340352870)表白:我喜欢你很久了!”
def extractContent(message):
    content = self_match_pattern.sub('', message)
    #通过‘:’分割出表白对象和表白内容
    content_s = content.split(') ', 1)
    #name = content_s[0].split('跟', 1)[-1].split('(',1)[0]
    #uid = content_s[0].split('跟', 1)[-1].split('(',1)[-1].split(')',1)[0]
    content = content_s[-1]
    #print 'name: '+name+'  \tuid: '+uid+'\tcontent: '+content
    return content


# 将不同类型的消息统一成同一种形式
def getNotiData(data):