URS

JosephLai241MIT更新放缓

一条命令就能把 Reddit 的帖子、评论和用户数据批量抓取下来,导出成 CSV 或 JSON,方便做数据分析和存档。

Universal Reddit Scraper - A comprehensive Reddit scraping/archival command-line tool.

v3.4.0发布于 2023-05-11 14:46 UTC1,045star127fork同步于 2026-11-07 07:34 UTC

怎么上手

由 README 提炼,执行前请确认
README 未给出安装命令,使用说明见 https://josephlai241.github.io/URS
硬件要求按 README 说明

README 未说明

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

基于 PRAW 的 Reddit 抓取命令行工具,抓帖子、评论并做词频与词云分析

一条命令就能把 Reddit 的帖子、评论和用户数据批量抓取下来,导出成 CSV 或 JSON,方便做数据分析和存档。

核心能力

  • 通过 PRAW 抓取 Subreddit、Redditor 和帖子评论
  • 实时监听 Subreddit 或用户的新帖与新评论
  • 对抓取结果生成词频统计
  • 根据抓取结果生成词云
  • 支持导出 CSV 并检查 PRAW 速率限制

容易踩的坑

需要自行准备 Reddit API 凭据供 PRAW 使用;完整用法已移到独立 mdBook 手册,README 不再包含全部参数说明;词云功能可能依赖额外 Python 库,README 未说明

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v3.4.0
  1. v3.4.0URS v3.4.0最新正式版2023-05-11 · 2023-05-11 14:46 UTC

    Summary

    This release contains code cleanup by upgrading the project structure to a Poetry project, and refactoring a compute-heavy bottleneck within this program in Rust, drastically improving performance.

    Changelog

    Added

    • taisun - A Python module written in Rust that contains the depth-first search algorithm and associated data structures for structured comments scraping. This library will eventually contain additional code that handles compute-heavy tasks.
    • GitHub Actions Workflows
      • rust.yml - Format and lint Rust code.
      • python.yml - Format and test Python code.
      • manual.yml - Build and deploy the mdBook manual to GitHub Pages.
    • A new user guide/manual built from mdBook.
    • Added type hints to all urs/ code.

    Changed

    • Dates used in this program have been updated to use the ISO8601 timestamp format (YYYY-MM-DD HH:MM:SS).
    • Docstrings have been updated from NumPy to reStructuredText format.
    • Simplifying the STYLE_GUIDE.md - The style is dictated by Black and isort for Python code, and rustfmt for Rust.
    • Simplifying the README.md
      • Most information previously listed there has been moved to the user guide/manual.
    • Formatted every single Python file with Black and isort.
    • Upgraded/recorded new demo GIFs.

    Deprecated

    N/A

  2. v3.3.2URS v3.3.22021-07-22 · 2021-07-22 20:30 UTC
    查看更新说明

    Summary

    This release fixes an open issue.

    PRAW v7.3.0 changed the Redditor object's subreddit attribute. This change breaks the Redditor scraper. It would be nice if all the tools worked as advertised.

    Full Changelog

    Added

    • Source code
      • In Redditor.py:
        • Added a new method GetInteractions._get_user_subreddit() - extracts subreddit data from the UserSubreddit object into a dictionary.
    • Tests
      • In test_Redditor.py:
        • Added TestGetUserSubredditMethod().test_get_user_subreddit() to test the new method.

    Changed

    • Source code
      • In Redditor.py:
        • GetInteractions._get_user_info() calls the new GetInteractions._get_user_subreddit() method to set the Redditor's subreddit data within the main Redditor information dictionary.
      • In Version.py:
        • Incremented version number.
    • README
      • Incremented PRAW badge version number.
  3. v3.3.1URS v3.3.12021-07-03 · 2021-07-03 20:07 UTC
    查看更新说明

    Summary

    • Introduced a new utility, -t, which will display a visual tree of the current day's scrape directory by default. Optionally, include a different date to display that day's scrape directory.
    • Move CI providers from Travis-CI to GitHub Actions.
      • Travis-CI is no longer free - there is now a free build cap.
    • Minor code refactoring and issue resolution.

    Full Changelog

    Added

    • User interface
      • Added a new utility:
        • -t/--tree - display the directory structure of the current date directory. Or optionally include a date to display that day's scrape directory.
    • Source code
      • Added a new file Utilities.py to the urs/utils module.
        • Added a class DateTree which contains methods to find and build a visual tree for the target date's directory.
          • Added logging when this utility is run.
      • Added an additional Halo to the wordcloud generator.
    • README
      • Added new "Utilities" section.
        • This section describes how to use the -t/--tree and --check utility flags.
      • Added new "Sponsors" section.
    • Tests
      • Added test_Utilities.py under the test_utils module.

    Changed

    • Source code
      • Refactored the following methods within the analytics module:
        • GetPath.get_scrape_type()
        • GetPath.name_file()
        • FinalizeWordcloud().save_wordcloud()
          • Implemented pathlib's Path() method to get the path.
      • Upgraded all string formatting from old-school Python formatting (using the % operator) to the superior f-string.
      • Updated GitHub Actions workflow pytest.yml.
        • This workflow was previously disabled. The workflow has been upgraded to test URS on all platforms (ubuntu-latest, macOS-latest, and windows-latest) and to send test coverage to Codecov after testing completes on ubuntu-latest.
    • README
      • Changed the Travis-CI badge to a GitHub Actions badge.
        • Updated badge link to route to the workflows page within the repository.
    • Tests
      • Upgraded all string formatting from old-school Python formatting (using the % operator) to the superior f-string in the following modules:
        • test_utils/test_Export.py
        • test_praw_scrapers/test_live_scrapers/test_Livestream.py
      • Refactored two tests within test_Export.py:
        • TestExportWriteCSVAndWriteJSON().test_write_csv()
        • TestExportExportMethod().test_export_write_csv()
    • Community documents
      • Updated PULL_REQUEST_TEMPLATE.md.
        • Removed Travis-CI configuration block.

    Deprecated

    • Source code
      • Removed .travis.yml - URS no longer uses Travis-CI as its CI provider.
  4. v3.3.0URS v3.3.02021-06-15 · 2021-06-15 03:17 UTC
    查看更新说明

    Summary

    • Introduced livestreaming tools:
      • Livestream comments or submissions submitted within Subreddits.
      • Livestream comments or submissions submitted by a Redditor.

    Full Changelog

    Added

    • User interface
      • Added livestream scraper flags:
        • -lr - livestream a Subreddit
        • -lu - livestream a Redditor
        • Added livestream scrape control flags to limit stream exclusively to submissions (default is streaming comments):
          • --stream-submissions
      • Added a flag -v/--version to display the version number.
    • Source code
      • Added a new sub-module live_scrapers within praw_scrapers for livestream functionality:
        • Livestream.py
        • utils/DisplayStream.py
        • utils/StreamGenerator.py
      • Added a new file Version.py to single-source the package version.
      • Added a gallery_data and media_metadata check in Comments.py, which includes the above fields if the submission contains a gallery.
    • README
      • Added a new "Installation" section with updated installation procedures.
      • Added a new section "Livestreaming Subreddits and Redditors" with sub-sections containing details for each flag.
      • Updated the Table of Contents accordingly.
    • Tests
      • Added additional unit tests for the live_scrapers module. These tests are located in tests/test_praw_scrapers/test_live_scrapers:
        • tests/test_praw_scrapers/test_live_scrapers/test_Livestream.py
        • tests/test_praw_scrapers/test_live_scrapers/test_utils/test_DisplayStream.py
        • tests/test_praw_scrapers/test_live_scrapers/test_utils/test_StreamGenerator.py
    • Repository documents
      • Added a Table of Contents for The Forest.md

    Changed

    • User interface
      • Updated the usage menu to clarify which tools may use which optional flags.
    • Source code
      • Reindexed the praw_scrapers module:
        • Moved the following files into the new static_scrapers sub-module:
          • Basic.py
          • Comments.py
          • Redditor.py
          • Subreddit.py
        • Updated absolute imports throughout the source code.
      • Moved confirm_options(), previously located in Subreddit.py to Global.py.
      • Moved PrepRedditor.prep_redditor() algorithm to its own class method PrepMutts.prep_mutts().
        • Added additional error handling to the algorithm to fix the KeyError exception mentioned in the Issue Fix or Enhancement Request section.
      • Removed Colorama's init() method from many modules - it only needs to be called once and is now located in Urs.py.
      • Updated requirements.txt.
    • README
      • The "Exporting" section is now one large section and is now located on top of the "URS Overview" section.
    • Tests
      • Updated absolute imports for existing PRAW scrapers.
      • Removed a few tests for DirInit.py since the make_directory() and make_type_directory() methods have been deprecated.

    Deprecated

    • Source code
      • Removed many methods defined in the InitializeDirectory class in DirInit.py:
        • LogMissingDir.log()
        • create()
        • make_directory()
        • make_type_directory()
        • make_analytics_directory()
          • Replaced these methods with a more versatile create_dirs() method.
  5. v3.2.1URS v3.2.12021-03-28 · 2021-03-28 04:53 UTC
    查看更新说明

    Release date: March 28, 2021

    Summary

    • Structured comments export has been upgraded to include comments of all levels.
      • Structured comments are now the default export format. Exporting to raw format requires including the --raw flag.
    • Tons of metadata has been added to all scrapers. See the Full Changelog section for a full list of attributes that have been added.
    • Credentials.py has been deprecated in favor of .env to avoid hard-coding API credentials.
    • Added more terminal eye candy - Halo has been implemented to spice up the output.

    Full Changelog

    Added

    • User interface
      • Added Halo to spice up the output while maintaining minimalism.
    • Source code
      • Created a comment Forest and accompanying CommentNode.
        • The Forest contains methods for inserting CommentNodes, including a depth-first search algorithm to do so.
      • Subreddit.py has been refactored and submission metadata has been added to scrape files:
        • "author"
        • "created_utc"
        • "distinguished"
        • "edited"
        • "id"
        • "is_original_content"
        • "is_self"
        • "link_flair_text"
        • "locked"
        • "name"
        • "num_comments"
        • "nsfw"
        • "permalink"
        • "score"
        • "selftext"
        • "spoiler"
        • "stickied"
        • "title"
        • "upvote_ratio"
        • "url"
      • Comments.py has been refactored and submission comments now include the following metadata:
        • "author"
        • "body"
        • "body_html"
        • "created_utc"
        • "distinguished"
        • "edited"
        • "id"
        • "is_submitter"
        • "link_id"
        • "parent_id"
        • "score"
        • "stickied"
      • Major refactor for Redditor.py on top of adding additional metadata.
        • Additional Redditor information has been added to scrape files:
          • "has_verified_email"
          • "icon_img"
          • "subreddit"
          • "trophies"
        • Additional Redditor comment, submission, and multireddit metadata has been added to scrape files:
          • subreddit objects are nested within comment and submission objects and contain the following metadata:
            • "can_assign_link_flair"
            • "can_assign_user_flair"
            • "created_utc"
            • "description"
            • "description_html"
            • "display_name"
            • "id"
            • "name"
            • "nsfw"
            • "public_description"
            • "spoilers_enabled"
            • "subscribers"
            • "user_is_banned"
            • "user_is_moderator"
            • "user_is_subscriber"
          • comment objects will contain the following metadata:
            • "type"
            • "body"
            • "body_html"
            • "created_utc"
            • "distinguished"
            • "edited"
            • "id"
            • "is_submitter"
            • "link_id"
            • "parent_id"
            • "score"
            • "stickied"
            • "submission" - contains additional metadata
            • "subreddit_id"
          • submission objects will contain the following metadata:
            • "type"
            • "author"
            • "created_utc"
            • "distinguished"
            • "edited"
            • "id"
            • "is_original_content"
            • "is_self"
            • "link_flair_text"
            • "locked"
            • "name"
            • "num_comments"
            • "nsfw"

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译
     __  __  _ __   ____
    /\ \/\ \/\`'__\/',__\
    \ \ \_\ \ \ \//\__, `\
     \ \____/\ \_\\/\____/
      \/___/  \/_/ \/___/
    

    Universal Reddit Scraper - A comprehensive Reddit scraping command-line tool written in Python.

    GitHub Workflow Status (Python) GitHub Workflow Status (Rust) Codecov GitHub release (latest by date) Total lines License

    Sponsors

    Table of Contents

    Contact

    Whether you are using URS for enterprise or personal use, I am very interested in hearing about your use case and how it has helped you achieve a goal. Additionally, please send me an email if you would like to contribute, have questions, or want to share something you have built on top of it.

    You can send me an email by clicking on the badge. I look forward to hearing from you!

    ProtonMail

    Introduction

    This is a comprehensive Reddit scraping tool that integrates multiple features:

    • Scrape Reddit via PRAW (the official Python Reddit API Wrapper)
      • Scrape Subreddits
      • Scrape Redditors
      • Scrape submission comments
    • Livestream Reddit via PRAW
      • Livestream comments submitted within Subreddits or by Redditors
      • Livestream submissions submitted within Subreddits or by Redditors
    • Analytical tools for scraped data
      • Generate frequencies for words that are found in submission titles, bodies, and/or comments
      • Generate a wordcloud from scrape results

    Usage Overview

    [-h]
    [-e]
    [-v]
    
    [-t [<optional_date>]]
    [--check]
    
    [-r <subreddit> <(h|n|c|t|r|s)> <n_results_or_keywords> [<optional_time_filter>]]
        [-y]
        [--csv]
        [--rules]
    [-u <redditor> <n_results>]
    [-c <submission_url> <n_results>]
        [--raw]
    [-b]
        [--csv]
    
    [-lr <subreddit>]
    [-lu <redditor>]
    
        [--nosave]
        [--stream-submissions]
    
    [-f <file_path>]
        [--csv]
    [-wc <file_path> [<optional_export_format>]]
        [--nosave]
    

    "Where’s the Manual?"

    URS Manual

    This README has become too long to comfortably contain all usage information for this tool. Consequently, the information that used to be in this file has been moved to a separate manual created with mdBook, a Rust command-line tool for creating books from Markdown files.

    Note: You can also find the link in the About sidebar in this repository.

    Demo GIFs

    Here are all the demo GIFs recorded for URS.

    Note: The nd command is nomad, a modern tree alternative I wrote in Rust.

    Subreddit Scraping

    subreddit demo

    Redditor Scraping

    redditor demo

    Submission Comments Scraping

    submission comments demo

    Livestreaming Reddit

    livestream subreddit demo

    Generating Word Frequencies

    frequencies demo

    Generating Wordclouds

    wordcloud demo

    Checking PRAW Rate Limits

    check praw rate limits demo

    Displaying Directory Tree

    display directory tree demo