我想寫一個遞歸函數,可以從Reddit提交中檢索嵌套註釋。我使用Python + PRAW def _get_comments(comments, ret = []):
for comment in comments:
if len(comment._replies) > 0:
return _get_comments(tail(comments), ret +
Basic代碼: import praw
r = praw.Reddit(user_agent='Getting the data!!')
r.login("username","password",disable_warning=True)
results=r.search('whatever', subreddit=None, sort=None, syntax=None, period
我試圖從subreddit刮所有評論。我找到了一個名爲PRAW的圖書館。舉例 import praw
r = praw.Reddit('Comment parser example by u/_Daimon_')
subreddit = r.get_subreddit("python")
comments = subreddit.get_comments()
但是,這隻返回最近的25條評
我正在使用praw模塊,並且我發現我的對象有時有一個屬性subreddit,有時是一個字符串,有時候是一個對象擁有自己的特性。我已經處理它使用以下內容: for c in comments:
if isinstance(c.subreddit, str):
subreddit_name = c.subreddit
else:
subreddit_name
import praw
import time
r = praw.Reddit(user_agent = "A bot by /u/")
r.login()
print("Logging in...")
cache = []
def run_bot():
print("Grabbing subreddit...")
subreddit = r.get_sub
我一直在試圖安裝praw與PIP安裝praw但不斷收到此錯誤信息: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 223, in main
status = self.run(options