【问题标题】:How to get Reddit comments based on (post_id , comment_id) only?如何仅基于 (post_id , comment_id) 获取 Reddit 评论?
【发布时间】:2021-09-25 18:38:36
【问题描述】:

我有一个包含 (post_ids,comment_ids) 的文件。如何仅基于这两列提取 Reddit cmets?我没有任何其他信息,例如 SubReddit_name、url 等。

【问题讨论】:

    标签: comments extract reddit


    【解决方案1】:

    您可以仅使用评论 ID 提取评论数据。您可以使用 Reddit API 获取完整的评论 JSON 对象。这是example 的操作方法。我建议在它之上实施一个速率限制器,这样你就不会被列入黑名单(或者使用像 this 这样的内置速率限制的工具。

    将评论 ID 传递给 Reddit API 时,请确保在它们前面加上 t1_ 前缀。因此,如果评论 id 是 hcve9uq,您将传递 t1_hcve9uq

    给定评论 ID 的 Reddit API 结果示例:

    GET https://www.reddit.com/api/info.json?id=t1_hcve9uq

    {
       "kind":"Listing",
       "data":{
          "after":null,
          "dist":1,
          "modhash":"fy7jn1i12yf3857a406ac27f7cf265489515da1f41d290f770",
          "geo_filter":"",
          "children":[
             {
                "kind":"t1",
                "data":{
                   "total_awards_received":0,
                   "approved_at_utc":null,
                   "author_is_blocked":false,
                   "comment_type":null,
                   "edited":false,
                   "mod_reason_by":null,
                   "banned_by":null,
                   "author_flair_type":"richtext",
                   "removal_reason":null,
                   "link_id":"t3_pobe0r",
                   "author_flair_template_id":null,
                   "likes":null,
                   "replies":"",
                   "author_fullname":"t2_b9q002jq",
                   "saved":false,
                   "id":"hcve9uq",
                   "banned_at_utc":null,
                   "mod_reason_title":null,
                   "gilded":0,
                   "archived":false,
                   "collapsed_reason_code":null,
                   "no_follow":false,
                   "author":"Ermingardia",
                   "can_mod_post":false,
                   "created_utc":1631654752.0,
                   "send_replies":true,
                   "parent_id":"t1_hcvdmlw",
                   "score":395,
                   "approved_by":null,
                   "author_premium":false,
                   "mod_note":null,
                   "all_awardings":[
                      
                   ],
                   "subreddit_id":"t5_2wlj3",
                   "body":"Yes, I seriously disturbed his crypto signals!",
                   "awarders":[
                      
                   ],
                   "user_reports":[
                      
                   ],
                   "author_flair_css_class":"Training",
                   "name":"t1_hcve9uq",
                   "author_patreon_flair":false,
                   "downs":0,
                   "author_flair_richtext":[
                      {
                         "e":"text",
                         "t":"Redditor for 6 months."
                      }
                   ],
                   "is_submitter":true,
                   "body_html":"<div class=\"md\"><p>Yes, I seriously disturbed his crypto signals!</p>\n</div>",
                   "gildings":{
                      
                   },
                   "collapsed_reason":null,
                   "distinguished":null,
                   "associated_award":null,
                   "stickied":false,
                   "can_gild":true,
                   "top_awarded_type":null,
                   "author_flair_text_color":"dark",
                   "score_hidden":false,
                   "permalink":"/r/CryptoCurrency/comments/pobe0r/crypto_scammer_got_in_touch_with_me_he_didnt_know/hcve9uq/",
                   "num_reports":null,
                   "locked":false,
                   "report_reasons":null,
                   "created":1631654752.0,
                   "subreddit":"CryptoCurrency",
                   "author_flair_text":"Redditor for 6 months.",
                   "treatment_tags":[
                      
                   ],
                   "collapsed":false,
                   "subreddit_name_prefixed":"r/CryptoCurrency",
                   "controversiality":0,
                   "author_flair_background_color":"",
                   "collapsed_because_crowd_control":null,
                   "mod_reports":[
                      
                   ],
                   "subreddit_type":"public",
                   "ups":395
                }
             }
          ],
          "before":null
       }
    }
    

    【讨论】:

      猜你喜欢
      • 2016-10-23
      • 1970-01-01
      • 2013-04-09
      • 2020-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-15
      相关资源
      最近更新 更多