GithubHelp home page GithubHelp logo

weiborelation's Introduction

WeiBoRelation

微博关系分析/爬取微博的所有关注和所有粉丝

Warnning

当前版本的代码存在一些问题,例如获取粉丝时会有重复。以及有些函数不够鲁棒
因为之前的API几乎不能用了,所以花了些时间更新了一下,但现在又没太多精力搞这个。
总之就是,现在的代码勉强能实现一些功能,但很不完美。所以仅供参考。

Feature

  • 获取指定用户关注的所有人的昵称、粉丝数、个人主页URL
  • 获取指定用户的所有粉丝的昵称、粉丝数、个人主页URL
  • 获取指定用户最近点赞的一条微博的URL

Usage

    w = WEIBO()
    w.WBID = "WBID"
    w.login()
    w.get_all_follow(max_fans=1000)
    w.get_all_fans(max_fans=1000)
    w.get_recent_liked()
    #get someone's fans and follow
    w.getRelationData(WBID, max_fans=1000)
    #get someone's fans's fans and follow & follow's fans and follow
    w.discoverRelation(max_fans=1000)
    
    #搜索潜在的可能认识的人
    F=Find("WBID")
    F.getRelation()
    F.sortSomeOne()

见其名,知其意。函数的具体意思就不用解释了吧。登陆的微博可以随便用,因为查看微博的某些信息需要登陆。

WBID是要查看的微博用户的ID,有些用户是weibo.com/u/后面的一串数字。有些设置了个性域的需要查看网页源代码,其中的$CONFIG['oid']就是了

Requirements

requests==2.21.0

beautifulsoup4==4.9.0

Tips

  • 获取粉丝数是为了排除一些粉丝很多的公众人物。可以对WEIBO中的方法进行改造,以获取粉丝数量在指定数目以下的关注/粉丝(已实现,通过max_fans参数设定)。然后你就可以顺藤摸瓜找到一些你朋友的微博(好吧,视奸确实有点变态)
  • 配合其他项目爬取所得用户的所有微博,尤其是图片,可以加快顺藤摸瓜的效率
  • 获取最近点赞的一条微博你应该知道该怎么用吧。你的女神刚给某个化妆品点了个赞,你第二天就送了一个同款,你看是不是稳了。沦落到这种地步还想找女朋友?门都没有(好吧,监视确实有点变态)
  • 由于微博限制,只能获取前250页的粉丝,也就是5000个粉丝。这已经是最多的了。旧版手机端只有20页,每页10个;电脑端只能获取前10页,每页20个。
  • 搜索潜在的可能认识的人是通过抓取自己微博的所有粉丝以及粉丝的粉丝和关注,所有关注以及关注的关注和粉丝,在其中找到出现次数多的但是不在你的粉丝/关注中的人。也就是说这个人是你没有关注/粉丝,但是和你的几位朋友是互相或者单向关注的关系,那这个人可能就是你认识的人。暂时按出现次数排序了。实际上如果按互相关注,单向关注分配权重,结合相关联的人数等因素,应该会更真实。(甚至可以抓取评论、点赞情况作为参考)

ToDo

  • [2020-04-18更新]获取全部关注时没有异常处理,频率太高应该会被ban
  • 微博熟人圈子绘制
  • 代码是分几次写完的。命名什么的不够规范统一;有些写的不严谨、有些写的多余
  • 已知bug,在获取粉丝时会有重复,粉丝少时不出现,粉丝多时会出现。猜测是因为微博api问题。准备用数据库储存数据,来解决这个问题。

应该都会鸽掉

Update

[2020-04-18]更新找潜在可能认识的人
[2022-03-11]更新了部分API,不需要登录即可获取关注/粉丝信息

SomeThingMore

都看到这了,不给个star再走吗

weiborelation's People

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.