Giter Club home page Giter Club logo

weibo-crawler's Introduction

微博爬虫

爬取指定用户尽可能全面的信息。

已实现的功能

抓取用户个人基本信息。

抓取用户的所有微博,包括被转发的微博,支持长微博正文、图片ID和文件,可以只抓取指定日期后。

抓取用户互相关注的用户基本信息,可以包含间接互关,可以指定抓取用户粉丝门槛和数量上限。

使用方法

使用虚拟环境(推荐)

# 创建虚拟环境
python -m venv ./venv
# 进入虚拟环境
.\venv\Scripts\activate

安装依赖

pip install -r requirements.txt

获取cookie

访问新浪微博网页版,登录账号。

之后后按F12显示“开发人员工具”,按F5刷新,按图中依次点击,找到cookie并复制。cookie务必保密

获取cookie

配置和运行

首次运行将config_simple.json5复制为config.json5

配置config.json5后再次运行,将执行抓取

python main.py

数据保存

所有数据保存到 output以用户id命名的文件夹

  • 用户信息保存到 user.json
  • 微博保存到mblog.json
  • 互关保存到mutual_follow.json
  • 微博附图保存到 image

配置说明

config_simple.json5

实现计划

功能

  • 配置文件使用JSON5
  • 支持获取用户非互关的关注
  • 下载头条文章
  • 下载视频
  • 通过将接口的返回值保存到文件,减少重复的网络请求
  • 人类友好的显示抓取到的数据,特别是微博的附图

系统配置

  • 指定目标用户ID
  • 指定日期范围
  • cookie
  • 全局休息时间
  • 图片、视频休息时间

用户信息

  • 用户个人信息
  • 互相关注的用户基本信息
  • 保留不同时间爬取的不同版本的用户信息
  • 互动的用户id

微博信息

  • 原创微博正文内容
  • 转发微博正文内容
  • 原创图片
  • 转发图片
  • @的用户id
  • 原创头条文章内容
  • 转发头条文章内容
  • 原创视频
  • 转发视频

weibo-crawler's People

Contributors

yusitong1999 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

kekewind

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.