praw

Writing list of objects to csv file

允我心安 提交于 2019-12-11 05:48:49
问题 I am writing a python program that loops through reddit submissions, pulls data, and stores it as an object in a list. However I am having trouble writing that list to a csv file. The file is created but it just gives some kind of id tag for the objects. How should I change the csv code? Code import praw from datetime import datetime import pandas as pd class Submission: def __init__(self, time, score, title, text, ofReddit, serious): self.time = time self.score = score self.title = title

SSLError with PRAW?

江枫思渺然 提交于 2019-12-11 01:19:49
问题 I'm trying to get started with PRAW but I'm having issues using login(). I have the following piece of code: import praw r = praw.Reddit('This is a test bot') r.login('myRedditUsername','password') And I get the following error: requests.exceptions.SSLError: [Errno 1] _ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed Is there a way around this outside of disabling SSL? 回答1: According to praw SSLError during login from shared hosting: It appears that

IntegrityError: datatype mismatch in Python using praw

倖福魔咒の 提交于 2019-12-05 01:39:24
问题 I am trying to write a reddit bot that takes the word "fuck" and see how many people say that on reddit. Here is the code: import praw import time import re import sqlite3 username = "LewisTheRobot" password = "lewismenelaws" conn = sqlite3.connect('reddit') c = conn.cursor() r = praw.Reddit(user_agent = "Reddit bot") word_to_match = [r'\bfuck\b', r'\bfucking\b', r'\bfucks\b'] storage = [] r.login(username, password) def run_bot(): subreddit = r.get_subreddit("all") print("Grabbing subreddit!

Get all comments from a specific reddit thread in python

谁都会走 提交于 2019-12-03 16:42:42
问题 The official way, r = praw.Reddit('Comment Scraper 1.0 by u/_Daimon_ see ' 'https://praw.readthedocs.org/en/latest/' 'pages/comment_parsing.html') submission = r.get_submission(submission_id='11v36o') submission.replace_more_comments(limit=None, threshold=0) is extremely slow. Is there a way to speed this up? There are people that have extracted every reddit comment into a database, so there must be some way to do this quicker. 回答1: Edit: the new praw api (6.0.0) has lists() which make the

Get all comments from a specific reddit thread in python

我的梦境 提交于 2019-12-03 06:47:42
The official way, r = praw.Reddit('Comment Scraper 1.0 by u/_Daimon_ see ' 'https://praw.readthedocs.org/en/latest/' 'pages/comment_parsing.html') submission = r.get_submission(submission_id='11v36o') submission.replace_more_comments(limit=None, threshold=0) is extremely slow. Is there a way to speed this up? There are people that have extracted every reddit comment into a database, so there must be some way to do this quicker. Phylliida Edit: the new praw api (6.0.0) has lists() which make the job easier: This also handles AttributeError that might occure due to more_comments through the use

Python script receiving a UnicodeEncodeError: 'ascii' codec can't encode character

我与影子孤独终老i 提交于 2019-12-02 09:36:17
I have a simple Python script that pulls posts from reddit and posts them on Twitter. Unfortunately, tonight it began having issues that I'm assuming are because of someone's title on reddit having a formatting issue. The error that I'm reciving is: File "redditbot.py", line 82, in <module> main() File "redditbot.py", line 64, in main tweeter(post_dict, post_ids) File "redditbot.py", line 74, in tweeter print post+" "+post_dict[post]+" #python" UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 34: ordinal not in range(128) And here is my script: # encoding=utf8

Installing PRAW

笑着哭i 提交于 2019-12-02 03:39:46
问题 I would like to install PRAW so I can make reddit bots and stuff, but all the install guides are confusing to me so could someone explain how to as noob friendly as possible. I've had some experience with vanilla python. Thanks! 回答1: praw is best installed, according to the documentation, via pip . To install pip , you need setuptools . Here is a simple guide on installing pip via setuptools. Basically, download ez_setup.py and get-pip.py , two Python scripts that automatically get and

Installing PRAW

喜夏-厌秋 提交于 2019-12-02 02:14:50
I would like to install PRAW so I can make reddit bots and stuff, but all the install guides are confusing to me so could someone explain how to as noob friendly as possible. I've had some experience with vanilla python. Thanks! praw is best installed, according to the documentation , via pip . To install pip , you need setuptools . Here is a simple guide on installing pip via setuptools. Basically, download ez_setup.py and get-pip.py , two Python scripts that automatically get and install setuptools and pip . You'll want to run the following commands in the terminal in the same directory as

Getting more than 100 search results with PRAW?

筅森魡賤 提交于 2019-11-29 20:05:33
问题 I'm using the following code to obtain reddit search results with PRAW 4.4.0: params = {'sort':'new', 'time_filter':'year'} return reddit.subreddit(subreddit).search('', **params) I'd like to scrape an indefinite amount of posts from the subreddit, for a period of up to a year. Reddit's search functionality (and correspondingly, their API) achieves this with the 'after' parameter. However, the above search function doesn't accept 'after' as a parameter. Is there a way to use PRAW's .search()