예제 #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
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()
예제 #4
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()
예제 #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)
        bot = RenRen()
        bot._loginByCookie(r.get('xiaohuangji_cookies'))
        bot.email = ''
        if bot.token:
            return [bot]
        else:
            return []
예제 #7
0
#!/usr/bin/env python
#-*- coding: utf-8 -*-

from renren import RenRen

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

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