MediaCrawler

MediaCrawler

社交媒体数据爬虫工具 支持多平台内容采集

MediaCrawler是一款开源的社交媒体数据爬虫工具,支持小红书、抖音、快手等多个主流平台。该工具可采集视频、图片、评论等内容,提供关键词搜索、指定ID爬取等功能。项目采用Playwright技术简化逆向过程,并集成了登录态缓存、IP代理等实用特性。MediaCrawler为社交媒体数据分析提供了便捷的数据采集解决方案。

爬虫数据采集社交媒体Playwright自动化Github开源项目

免责声明:

请以学习为目的使用本仓库,爬虫违法违规案例:https://github.com/HiddenStrawberry/Crawler_Illegal_Cases_In_China <br>

本仓库的所有内容仅供学习和参考之用,禁止用于商业用途。任何人或组织不得将本仓库的内容用于非法用途或侵犯他人合法权益。本仓库所涉及的爬虫技术仅用于学习和研究,不得用于对其他平台进行大规模爬虫或其他非法行为。对于因使用本仓库内容而引起的任何法律责任,本仓库不承担任何责任。使用本仓库的内容即表示您同意本免责声明的所有条款和条件。

点击查看更为详细的免责声明。点击跳转

仓库描述

小红书爬虫抖音爬虫快手爬虫B站爬虫微博爬虫百度贴吧...。 目前能抓取小红书、抖音、快手、B站、微博的视频、图片、评论、点赞、转发等信息。

原理:利用playwright搭桥,保留登录成功后的上下文浏览器环境,通过执行JS表达式获取一些加密参数。 通过使用此方式,免去了复现核心加密JS代码,逆向难度大大降低。

MediaCrawlerPro版本经过2个周的通宵,已经迭代出来了,相较于现在有一些优势:

  • 多账号+IP代理支持(重点!)
  • 去除Playwright依赖,使用更加简单
  • 支持linux部署(Docker docker-compose)
  • 代码重构优化,更加易读易维护

功能列表

平台关键词搜索指定帖子ID爬取二级评论指定创作者主页登录态缓存IP代理池生成评论词云图
小红书
抖音
快手
B 站
微博
贴吧

使用方法

创建并激活 python 虚拟环境

# 进入项目根目录 cd MediaCrawler # 创建虚拟环境 # 注意python 版本需要3.7 - 3.9 高于该版本可能会出现一些依赖包兼容问题 python -m venv venv # macos & linux 激活虚拟环境 source venv/bin/activate # windows 激活虚拟环境 venv\Scripts\activate

安装依赖库

pip install -r requirements.txt

安装 playwright浏览器驱动

playwright install

运行爬虫程序

### 项目默认是没有开启评论爬取模式,如需评论请在config/base_config.py中的 ENABLE_GET_COMMENTS 变量修改 ### 一些其他支持项,也可以在config/base_config.py查看功能,写的有中文注释 # 从配置文件中读取关键词搜索相关的帖子并爬取帖子信息与评论 python main.py --platform xhs --lt qrcode --type search # 从配置文件中读取指定的帖子ID列表获取指定帖子的信息与评论信息 python main.py --platform xhs --lt qrcode --type detail # 打开对应APP扫二维码登录 # 其他平台爬虫使用示例,执行下面的命令查看 python main.py --help

数据保存

  • 支持保存到关系型数据库(Mysql、PgSQL等)
    • 执行 python db.py 初始化数据库数据库表结构(只在首次执行)
  • 支持保存到csv中(data/目录下)
  • 支持保存到json中(data/目录下)

加入MediaCrawler爬虫项目交流群。点击跳转加入

开发者服务

Thanks to the following Sponsors for supporting this repository

  • <a href="https://www.kuaidaili.com/?ref=ldwkjqipvz6c">【Fast Proxy】Enterprise-level proxy IP service, fast and stable, safe and reliable. The best choice for crawler engineers.</a> <a href="https://www.kuaidaili.com/?ref=ldwkjqipvz6c" target="_blank"><img src="https://yellow-cdn.veclightyear.com/835a84d5/03be7c84-9006-43a0-8e29-5ee492cb15b4.png" alt="【Fast Proxy】Enterprise-level proxy IP service, fast and stable, safe and reliable. The best choice for crawler engineers."></a><br>

  • <a href="https://sider.ai/ad-land-redirect?source=github&p1=mi&p2=kk">Sider, the most popular ChatGPT plugin on the internet. I've been using it for free for almost a year, and the experience is excellent.</a>

Become a sponsor and showcase your product here to gain daily exposure. Contact the author on WeChat: yzglan

Donations

If you find this project helpful, you can make a donation. Your support is my greatest motivation!

When making a donation, you can leave a note with your name, and I will add you to the donation list.

<p> <img alt="Donation-WeChat" src="https://yellow-cdn.veclightyear.com/835a84d5/84204761-afd6-40d9-8d39-856987c827fd.jpeg" style="width: 200px;margin-right: 140px;" /> <img alt="Donation-Alipay" src="https://yellow-cdn.veclightyear.com/835a84d5/3f55e6f7-e497-445c-bc76-d913f893162a.png" style="width: 200px" /> </p>

View donation list Click to jump

MediaCrawler Crawler Project Discussion Group:

<div id="join_wechat_group">

Scan my personal WeChat QR code below and note "github" to be added to the MediaCrawler project discussion group (please make sure to note "github", a WeChat assistant will automatically add you to the group)

If the image doesn't display, you can directly add my WeChat ID: yzglan

<div style="max-width: 200px"> <p><img alt="relakkes_wechat" src="https://yellow-cdn.veclightyear.com/835a84d5/6f6f23d2-95d1-4872-be4c-0801bfb76921.JPG" style="width: 200px;height: 100%" ></p> </div> </div>

Common Q&A for Runtime Errors

Try to search and solve problems on your own first. AI is very popular now, and ChatGPT can solve most of your problems in many cases Free ChatGPT

➡️➡️➡️ Common Issues

Douyin and Xiaohongshu now use Playwright for login, which will have slider verification + SMS verification. Please manually complete this process.

Project Code Structure

➡️➡️➡️ Project Code Structure Description

Proxy IP Usage Instructions

➡️➡️➡️ Proxy Usage Instructions

Word Cloud Related Operation Instructions

➡️➡️➡️ Word Cloud Related Instructions

Mobile Number Login Instructions

➡️➡️➡️ Mobile Number Login Instructions

Crawler Beginner Course

I've started a new crawler tutorial Github repository CrawlerTutorial. Interested friends can follow it. It's continuously updated and completely free.

项目贡献者

感谢你们的贡献,让项目变得更好!(贡献比较多的可以加我微信,免费拉你进我的知识星球,后期还有一些其他福利。)

<!-- readme: contributors -start --> <table> <tbody> <tr> <td align="center"> <a href="https://github.com/NanmiCoder"> <img src="https://avatars.githubusercontent.com/u/47178017?v=4" width="100;" alt="NanmiCoder"/> <br /> <sub><b>程序员阿江-Relakkes</b></sub> </a> </td> <td align="center"> <a href="https://github.com/leantli"> <img src="https://avatars.githubusercontent.com/u/117699758?v=4" width="100;" alt="leantli"/> <br /> <sub><b>leantli</b></sub> </a> </td> <td align="center"> <a href="https://github.com/Rosyrain"> <img src="https://avatars.githubusercontent.com/u/116946548?v=4" width="100;" alt="Rosyrain"/> <br /> <sub><b>Rosyrain</b></sub> </a> </td> <td align="center"> <a href="https://github.com/BaoZhuhan"> <img src="https://avatars.githubusercontent.com/u/140676370?v=4" width="100;" alt="BaoZhuhan"/> <br /> <sub><b>包诸涵</b></sub> </a> </td> <td align="center"> <a href="https://github.com/nelzomal"> <img src="https://avatars.githubusercontent.com/u/8512926?v=4" width="100;" alt="nelzomal"/> <br /> <sub><b>周楠</b></sub> </a> </td> <td align="center"> <a href="https://github.com/helloteemo"> <img src="https://avatars.githubusercontent.com/u/46838719?v=4" width="100;" alt="helloteemo"/> <br /> <sub><b>helloteemo</b></sub> </a> </td> </tr> <tr> <td align="center"> <a href="https://github.com/Ermeng98"> <img src="https://avatars.githubusercontent.com/u/55784769?v=4" width="100;" alt="Ermeng98"/> <br /> <sub><b>二梦</b></sub> </a> </td> <td align="center"> <a href="https://github.com/PeanutSplash"> <img src="https://avatars.githubusercontent.com/u/98582625?v=4" width="100;" alt="PeanutSplash"/> <br /> <sub><b>花生溅射</b></sub> </a> </td> <td align="center"> <a href="https://github.com/Hiro-Lin"> <img src="https://avatars.githubusercontent.com/u/40111864?v=4" width="100;" alt="Hiro-Lin"/> <br /> <sub><b>HIRO</b></sub> </a> </td> <td align="center"> <a href="https://github.com/henryhyn"> <img src="https://avatars.githubusercontent.com/u/5162443?v=4" width="100;" alt="henryhyn"/> <br /> <sub><b>亨利 何</b></sub> </a> </td> <td align="center"> <a href="https://github.com/Akiqqqqqqq"> <img src="https://avatars.githubusercontent.com/u/51102894?v=4" width="100;" alt="Akiqqqqqqq"/> <br /> <sub><b>leonardoqiuyu</b></sub> </a> </td> <td align="center"> <a href="https://github.com/jayeeliu"> <img src="https://avatars.githubusercontent.com/u/77389?v=4" width="100;" alt="jayeeliu"/> <br /> <sub><b>jayeeliu</b></sub> </a> </td> </tr> <tr> <td align="center"> <a href="https://github.com/fruitswordman"> <img src="https://avatars.githubusercontent.com/u/103844614?v=4" width="100;" alt="fruitswordman"/> <br /> <sub><b>吕文博</b></sub> </a> </td> <td align="center"> <a href="https://github.com/ZhouXsh"> <img src="https://avatars.githubusercontent.com/u/131248181?v=4" width="100;" alt="ZhouXsh"/> <br /> <sub><b>ZhouXsh</b></sub> </a> </td> <td align="center"> <a href="https://github.com/ZuWard"> <img src="https://avatars.githubusercontent.com/u/38209256?v=4" width="100;" alt="ZuWard"/> <br /> <sub><b>ZuWard</b></sub> </a> </td> <td align="center"> <a href="https://github.com/Zzendrix"> <img src="https://avatars.githubusercontent.com/u/154900254?v=4" width="100;" alt="Zzendrix"/> <br /> <sub><b>Zendrix</b></sub> </a> </td> <td align="center"> <a href="https://github.com/chunpat"> <img src="https://avatars.githubusercontent.com/u/19848304?v=4" width="100;" alt="chunpat"/> <br /> <sub><b>张振鹏</b></sub> </a> </td> <td align="center"> <a href="https://github.com/tanpenggood"> <img src="https://avatars.githubusercontent.com/u/37927946?v=4" width="100;" alt="tanpenggood"/> <br /> <sub><b>谭鹏</b></sub> </a> </td> </tr> <tr> <td align="center"> <a href="https://github.com/xbsheng"> <img src="https://avatars.githubusercontent.com/u/56357338?v=4" width="100;" alt="xbsheng"/> <br /> <sub><b>xbsheng</b></sub> </a> </td> <td align="center"> <a href="https://github.com/yangrq1018"> <img src="https://avatars.githubusercontent.com/u/25074163?v=4" width="100;" alt="yangrq1018"/> <br /> <sub><b>马丁</b></sub> </a> </td> <td align="center"> <a href="https://github.com/zhihuiio"> <img src="https://avatars.githubusercontent.com/u/165655688?v=4" width="100;" alt="zhihuiio"/> <br /> <sub><b>zhihuiio</b></sub> </a> </td> <td align="center"> <a href="https://github.com/renaissancezyc"> <img src="https://avatars.githubusercontent.com/u/118403818?v=4" width="100;" alt="renaissancezyc"/> <br /> <sub><b>任</b></sub> </a> </td> <td align="center"> <a href="https://github.com/Tianci-King"> <img src="https://avatars.githubusercontent.com/u/109196852?v=4" width="100;" alt="Tianci-King"/> <br /> <sub><b>王天赐</b></sub> </a> </td> <td align="center"> <a href="https://github.com/Styunlen"> <img src="https://avatars.githubusercontent.com/u/30810222?v=4" width="100;" alt="Styunlen"/> <br /> <sub><b>Styunlen</b></sub> </a> </td> </tr> <tr> <td align="center"> <a href="https://github.com/Schofi"> <img src="https://avatars.githubusercontent.com/u/33537727?v=4" width="100;" alt="Schofi"/> <br /> <sub><b>Schofi</b></sub> </a> </td> <td align="center"> <a href="https://github.com/Klu5ure"> <img src="https://avatars.githubusercontent.com/u/166240879?v=4" width="100;" alt="Klu5ure"/> <br /> <sub><b>Klu5ure</b></sub> </a> </td> <td align="center"> <a href="https://github.com/keeper-jie"> <img src="https://avatars.githubusercontent.com/u/33612777?v=4" width="100;" alt="keeper-jie"/> <br /> <sub><b>科米特</b></sub> </a> </td> <td align="center"> <a href="https://github.com/kexinoh"> <img src="https://avatars.githubusercontent.com/u/91727108?v=4" width="100;" alt="kexinoh"/> <br /> <sub><b>KEXNA</b></sub> </a> </td> <td align="center"> <a href="https://github.com/aa65535"> <img src="https://avatars.githubusercontent.com/u/5417786?v=4" width="100;" alt="aa65535"/> <br /> <sub><b>张健</b></sub> </a> </td> <td align="center"> <a href="https://github.com/Jasonyang2014"> <img src="https://avatars.githubusercontent.com/u/8269290?v=4" width="100;" alt="Jasonyang2014"/> <br /> <sub><b>欧阳</b></sub> </a> </td> </tr> <tr> <td align="center"> <a href="https://github.com/522109452"> <img src="https://avatars.githubusercontent.com/u/16929874?v=4" width="100;" alt="522109452"/> <br /> <sub><b>天青</b></sub> </a> </td> <td align="center"> <a href="https://github.com/3DRX"> <img src="https://avatars.githubusercontent.com/u/67278980?v=4" width="100;" alt="3DRX"/> <br /> <sub><b>康景阳</b></sub> </a> </td> </tr> </tbody> </table> ## star 趋势图 - 如果该项目对你有帮助,请给个 star ❤️❤️❤️

Star 历史图表

参考

捐赠信息

<div id="donate">

注:打赏时请备注捐赠者姓名,如有遗漏请联系我添加(有时消息较多可能会遗漏,十分抱歉)

捐赠者捐赠金额捐赠日期
*皓50 元2024-03-18
*刚50 元2024-03-18
*乐20 元2024-03-17
*木20 元2024-03-17
*诚20 元2024-03-17
Strem Gamer20 元2024-03-16
*鑫20 元2024-03-14
Yuzu20 元2024-03-07
**宁100 元2024-03-03
**媛20 元2024-03-03
Scarlett20 元2024-02-16
Asun20 元2024-01-30
何*100 元2024-01-21
allen20 元2024-01-10
llllll20 元2024-01-07
邝*元20 元2023-12-29
50chen50 元2023-12-22
xiongot20 元2023-12-17
atom.hu20 元2023-12-16
一呆20 元2023-12-01
坠落50 元2023-11-08
</div>

免责声明

<div id="disclaimer">

1. 项目目的与性质

本项目(以下简称"本项目")是作为一个技术研究与学习工具而创建的,旨在探索和学习网络数据采集技术。本项目专注于自媒体平台的数据爬取技术研究,旨在提供给学习者和研究者作为技术交流之用。

2. 法律合规性声明

本项目开发者(以下简称"开发者")郑重提醒用户在下载、安装和使用本项目时,严格遵守中华人民共和国相关法律法规,包括但不限于《中华人民共和国网络安全法》、《中华人民共和国反间谍法》等所有适用的国家法律和政策。用户应自行承担一切因使用本项目而可能引起的法律责任。

3. 使用目的限制

本项目严禁用于任何非法目的或非学习、非研究的商业行为。本项目不得用于任何形式的非法侵入他人计算机系统,不得用于任何侵犯他人知识产权或其他合法权益的行为。用户应保证其使用本项目的目的纯属个人学习和技术研究,不得用于任何形式的非法活动。

4. 免责声明

开发者已尽最大努力确保本项目的正当性及安全性,但不对用户使用本项目可能引起的任何形式的直接或间接损失承担责任。包括但不限于由于使用本项目而导致的任何数据丢失、设备损坏、法律诉讼等。

5. 知识产权声明

本项目的知识产权归开发者所有。本项目受到著作权法和国际著作权条约以及其他知识产权法律和条约的保护。用户在遵守本声明及相关法律法规的前提下,可以下载和使用本项目。

6. 最终解释权

关于本项目的最终解释权归开发者所有。开发者保留随时更改或更新本免责声明的权利,恕不另行通知。

</div>

感谢JetBrains提供的免费开源许可证支持

<a href="https://www.jetbrains.com/?from=MediaCrawler"> <img src="https://yellow-cdn.veclightyear.com/835a84d5/b718b52d-3fbb-4f63-b614-932d69395d78.png" width="100" alt="JetBrains" /> </a>

编辑推荐精选

Keevx

Keevx

AI数字人视频创作平台

Keevx 一款开箱即用的AI数字人视频创作平台,广泛适用于电商广告、企业培训与社媒宣传,让全球企业与个人创作者无需拍摄剪辑,就能快速生成多语言、高质量的专业视频。

即梦AI

即梦AI

一站式AI创作平台

提供 AI 驱动的图片、视频生成及数字人等功能,助力创意创作

扣子-AI办公

扣子-AI办公

AI办公助手,复杂任务高效处理

AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!

TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI辅助写作AI工具蛙蛙写作AI写作工具学术助手办公助手营销助手AI助手
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

热门AI助手AI对话AI工具聊天机器人
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

下拉加载更多