def get_formatted_weibo_tweets_by_name(name: str, with_comments: bool = False, pages: int = None) -> _TweetsResponse: """ Get formatted weibo tweets by nick name without any authorization >>> from weibo_scraper import get_formatted_weibo_tweets_by_name >>> result_iterator = get_formatted_weibo_tweets_by_name(name='嘻红豆', pages=None) >>> for user_meta in result_iterator: >>> for tweetMeta in user_meta.cards_node: >>> print(tweetMeta.mblog.text) :param name: nick name which you want to search :param pages: pages ,default all pages :return: _TweetsResponse """ if name == '': raise WeiBoScraperException( "name from <get_weibo_tweets_by_name> can not be blank!") egu_res = exist_get_uid(name=name) exist = egu_res.get("exist") uid = egu_res.get("uid") if exist: inner_tweet_containerid = get_tweet_containerid(uid=uid) yield from get_weibo_tweets_formatted( tweet_container_id=inner_tweet_containerid, with_comments=with_comments, pages=pages) else: yield None
def get_weibo_tweets_by_name(name: str, pages: int = None) -> _TweetsResponse: """ Get raw weibo tweets by nick name without any authorization >>> from weibo_scraper import get_weibo_tweets_by_name >>> for tweet in get_weibo_tweets_by_name(name='嘻红豆', pages=1): >>> print(tweet) :param name: nick name which you want to search :param pages: pages ,default all pages :return: _TweetsResponse """ if name == '': raise WeiBoScraperException("name from <get_weibo_tweets_by_name> can not be blank!") egu_res = exist_get_uid(name=name) exist = egu_res.get("exist") uid = egu_res.get("uid") if exist: inner_tweet_containerid = get_tweet_containerid(uid=uid) yield from get_weibo_tweets(tweet_container_id=inner_tweet_containerid, pages=pages) else: yield None
""" import sys import os import weibo_scraper from weibo_scraper import set_debug from weibo_base.weibo_component import exist_get_uid, get_tweet_containerid from weibo_base.weibo_util import Timer import logging if __name__ == '__main__': set_debug() uid = exist_get_uid(name='嘻红豆') print(uid) containerid = get_tweet_containerid(uid=uid.get('uid')) print(containerid) result = weibo_scraper.get_weibo_tweets_by_name(name="嘻红豆", pages=1) for tweet in result: print(tweet) result = weibo_scraper.get_weibo_tweets(tweet_container_id=containerid, pages=1) for tweet in result: print(tweet) wp = weibo_scraper.get_weibo_profile(name='嘻红豆') print(wp.raw_user_response) hotwords = weibo_scraper.get_realtime_hotwords() for hw in hotwords: