使用Praw 4.4.0在Python2.7虚拟env中构建Django 1.8 web应用程序。
该项目名为demonstration,有一个名为app的应用程序。

自动取款机

当转到:http://127.0.0.1:8000/app/profile/时,这是结果的一部分
app/views.py有以下配置文件代码:
# views.py
from django.shortcuts import render, HttpResponse
import requests
import praw
# Create your views here.
def profile(request):
reddit = praw.Reddit(client_id='client_id',
client_secret='client_secret',
username='username',
password='password',
user_agent='user_agent')
# assume you have a Reddit instance bound to variable `reddit`
subreddit = reddit.subreddit('redditdev')
print(subreddit.display_name) # Output: redditdev
print(subreddit.title) # Output: reddit Development
print(subreddit.description) # Output: A subreddit for discussion of ...正如您在第二个图像中所看到的,subreddit的名称将被打印出来。Great.
嗯,没那么好。这是在代码中编写的,所以它不是从Reddit获得的,请参见:
subreddit = reddit.subreddit('redditdev')
print(subreddit.display_name) # Output: redditdev一旦它真正尝试进入Reddit并吸收数据,结果就是:
print(subreddit.title) # Output: reddit Development
print(subreddit.description) # Output: A subreddit for discussion of ...01/3/2017 14:50:02"GET /app/profile/ HTTP/1.1“500 93288
使用Debug mode = True,您可以在页面中看到以下内容:

问题:不知何故不喜欢我的登录。
他们怎么会开始喜欢我并允许我打印数据呢?
,我能做得更好吗?
谢谢您一直鼓励我
\\一些有用的链接/
start.html
发布于 2017-03-01 16:00:29
已修复。问题是:
username='username',
password='password',把它取下来然后开始工作。

https://stackoverflow.com/questions/42535140
复制相似问题