praw

Keep getting attribute error using Praw to scrape specific search term in subreddit

試著忘記壹切 提交于 2021-02-11 12:28:01
问题 I'm an extreme novice. My goal is to scrape reddit posts and comments from the subreddit r/Coronavirus by the searchterm "smokers". I keep getting "AttributeError: 'MoreComments' object has no attribute 'body'" referring to the "commentsDict["Body"].append(topLevelComments.body)" line. There are two other lines using the (topLevelComments.author, .score, and .body) that keep causing it to crash. When I comment out all of the lines with ".append(topLevelComments. )it returns: ValueError(

Python praw reddit api: Reliably get posts as they are posted

别来无恙 提交于 2021-02-08 04:11:26
问题 At the moment I have a script that queries some subreddits every 30 seconds and returns the newest submission: while True: for post in reddit.subreddit(query_list).new(limit=1): if previous != post: # Do something previous = post time.sleep(30) The problem with this is that if there are more than two posts in that time frame it'll skip one of them. I know I can set a smaller wait time, or I can get more than one post at a time and sort through the results, but that doesn't really fix the

Python praw reddit api: Reliably get posts as they are posted

最后都变了- 提交于 2021-02-08 04:07:37
问题 At the moment I have a script that queries some subreddits every 30 seconds and returns the newest submission: while True: for post in reddit.subreddit(query_list).new(limit=1): if previous != post: # Do something previous = post time.sleep(30) The problem with this is that if there are more than two posts in that time frame it'll skip one of them. I know I can set a smaller wait time, or I can get more than one post at a time and sort through the results, but that doesn't really fix the

Python praw reddit api: Reliably get posts as they are posted

谁都会走 提交于 2021-02-08 04:03:38
问题 At the moment I have a script that queries some subreddits every 30 seconds and returns the newest submission: while True: for post in reddit.subreddit(query_list).new(limit=1): if previous != post: # Do something previous = post time.sleep(30) The problem with this is that if there are more than two posts in that time frame it'll skip one of them. I know I can set a smaller wait time, or I can get more than one post at a time and sort through the results, but that doesn't really fix the

Can you stream posts that have made it to “hot”?

◇◆丶佛笑我妖孽 提交于 2021-01-27 22:00:41
问题 So let's say that I want to stream posts from the subreddit "news". However the posts are very frequent and we can't say that every post is worthy. So I would like to filter the good posts by trying to stream the "hot" list. But I am not sure if that, or a similar thing is possible. Normally, this is what I do to stream posts: for submission in subreddit.stream.submissions(): if not submission.stickied: print(str(submission.title) + " " + str(submission.url) + "\n") And this would filter the

PRAW 6: Get all submission of a subreddit

久未见 提交于 2020-06-11 21:36:52
问题 I'm trying to iterate over submissions of a certain subreddit from the newest to the oldest using PRAW. I used to do it like this: subreddit = reddit.subreddit('LandscapePhotography') for submission in subreddit.submissions(None, time.time()): print("Submission Title: {}".format(submission.title)) However, when I try to do it now I get the following error: AttributeError: 'Subreddit' object has no attribute 'submissions' From looking at the docs I can't seem to figure out how to do this. The

PRAW 6: Get all submission of a subreddit

北慕城南 提交于 2020-06-11 21:36:39
问题 I'm trying to iterate over submissions of a certain subreddit from the newest to the oldest using PRAW. I used to do it like this: subreddit = reddit.subreddit('LandscapePhotography') for submission in subreddit.submissions(None, time.time()): print("Submission Title: {}".format(submission.title)) However, when I try to do it now I get the following error: AttributeError: 'Subreddit' object has no attribute 'submissions' From looking at the docs I can't seem to figure out how to do this. The

headers = {“Authorization”: “bearer ” + accessToken['access_token'], “User-Agent”: userAgent} KeyError: 'access_token'

不打扰是莪最后的温柔 提交于 2020-01-24 22:58:12
问题 I found this code in this SO's answer however when I run it I get this error: in redcom.py I have: import time import requests import requests.auth import praw username = 'myusername' userAgent = "reddit natural language processing " + username clientId = 'myclientid' clientSecret = "myclientsecret" password = "mypasswd" #app_uri = http://127.0.0.1:65010/authorize_callback def getPraw(): return praw.Reddit(user_agent=userAgent, client_id=clientId, client_secret=clientSecret) global

Printing a list in Flask

巧了我就是萌 提交于 2020-01-11 10:37:53
问题 I want the script to make a list of the news headlines that it grabs from Reddit and display them as a text output. However it seems like the return function prevents me from doing that as it only lists one title. from flask import Flask import praw import config app = Flask(__name__) @app.route('/') def index(): reddit = praw.Reddit(client_id=config.client_id, client_secret=config.client_secret, user_agent="...") for submission in reddit.subreddit('worldnews').controversial(limit=10): print