Beispiel #1
0
 def send_origin(self, mod_class_name, mod, pic_name):
     print("cron start")
     w = WeiBo(self.username, self.password)
     m = mod_class_name(mod, pic_name)
     content = m.make_content()
     pic_id = w.upload_pic("pic/%s.jpg" % pic_name)
     w.original_weibo(content, pic_id)
Beispiel #2
0
def fcl_weibo(weibo: WeiBo) -> None:
    LOG.info(f'weibo comment link: {weibo.comment_link}')
    LOG.info(f'weibo prettify: {weibo.prettify()}')
    tags = get_fcl_user_tag(weibo.username)
    LOG.info(f'weibo fc tags: {tags}')
    rc_code, l_code = weibo.repost_and_comment(tags), weibo.like()
    LOG.info(f'✔ {weibo.username}\t{rc_code}\t{l_code}')
    sleep(1)
Beispiel #3
0
 def get_user_id(self, username):  # uid
     session = self.Session()
     weibo_user = session.query(WeiboUser).filter_by(weibo_username=username).first()
     if not weibo_user:
         w = WeiBo(self.username, self.password)
         user_info = w.get_user_basic_info()
         print(user_info)
         if self.dom_user_info(self.username, self.password, user_info):
             print("已将微博账号信息存入数据库")
         weibo_user = session.query(WeiboUser).filter_by(weibo_username=username).first()
     uid = weibo_user.weibo_id
     return uid
Beispiel #4
0
 def forward(self):
     print("cron start")
     w = WeiBo(self.username, self.password)
     weibo_handle = WeiboHandle(self.username, self.password)
     weibo_content = weibo_handle.get_weibo_from_database()
     if not weibo_content:
         print("暂无微博")
         self.get_and_dom()
     content = "#食品青春# @南昌大学食品学院团委 @南昌大学食品学院学生会"
     result = w.forward_weibo(weibo_content, content)
     if not result:
         print("转发失败")
     weibo_handle.update_weibo(weibo_content)
Beispiel #5
0
 def get_and_dom(self):
     # print("cron start")
     # follows = self.w.get_user_follows()
     # for follow in follows:
     #    if self.weibo_handle.dom_weibo_follow(follow):
     #        print("已将微博账号的关注信息存入数据库")
     print("getting weibo from follows")
     w = WeiBo(self.username, self.password)
     weibo_handle = WeiboHandle(self.username, self.password)
     uids = weibo_handle.get_followed_from_database()
     q1 = Queue()
     q2 = Queue()
     for uid in uids:
         q1.put(uid)
     while not q1.empty():
         uid = q1.get()
         t = MyThread(func=w.get_user_weibo, args=(uid,))
         t.start()
         t.join()
         for data in t.get_result():
             q2.put(data)
     while not q2.empty():
         weibo = q2.get()
         t = MyThread(func=weibo_handle.dom_weibo, args=(weibo,))
         t.start()
         t.join()
Beispiel #6
0
def weibos_page_parser(page_soup: BeautifulSoup) -> iter:
    for weibo_tag in page_soup.select('div[id^="M_"]'):
        weibo = WeiBo(weibo_tag)
        comment_id = get_weibo_id_by_comment_link(weibo.comment_link)
        if comment_id in get_latest_fcl_comment_ids():
            raise ParsedWeiboError(
                f'last parse weibo: comment id is [{comment_id}]'
            )
        if not weibo_preposition_filter(weibo):
            continue
        LOG.info(f'-> [{weibo.username}]\t{weibo.fcl_panel}')
        yield weibo
    seconds_to_sleep = randint(3, 6)
    LOG.info(f'page sleep: {seconds_to_sleep}s')
    sleep(seconds_to_sleep)
Beispiel #7
0
import logging
import os
import json
import time

from config import WEIBO_PASSWORD, WEIBO_USERNAME
from weibo import WeiBo

if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO,
                        format="%(asctime)s\t%(levelname)s\t%(message)s")
    weibo = WeiBo()
    weibo.login(WEIBO_USERNAME, WEIBO_PASSWORD)
    weibo.get_myfollow()
Beispiel #8
0
import logging
import os
import json
import time

from config import WEIBO_PASSWORD, WEIBO_USERNAME
from weibo import WeiBo

if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO,
                        format="%(asctime)s\t%(levelname)s\t%(message)s")
    weibo = WeiBo()
    weibo.login(WEIBO_USERNAME, WEIBO_PASSWORD)
    weibo.del_mblog()