Bot.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:MyTwitterBot 作者: felipessalvatore 项目源码 文件源码
def get_trends(self, local):
        """
        Method to get the trending hashtags.

        :type local: str
        :rtype: list of str
        """
        session_string = "https://api.twitter.com/1.1/trends/place.json?id="
        local_id = self.get_local_identifier()[local]
        session_string += local_id
        session = OAuth1Session(ConsumerKey,
                                ConsumerSecret,
                                AccessToken,
                                AccessTokenSecret)
        response = session.get(session_string)
        if response.__dict__['status_code'] == 200:
            local_trends = json.loads(response.text)[0]["trends"]
            hashtags = [trend["name"]
                        for trend in local_trends if trend["name"][0] == '#']
        else:
            hashtags = []
        return hashtags
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号