首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误: REDDIT-API

错误: REDDIT-API
EN

Stack Overflow用户
提问于 2017-03-01 15:02:32
回答 1查看 303关注 0票数 3

使用Praw 4.4.0在Python2.7虚拟env中构建Django 1.8 web应用程序。

该项目名为demonstration,有一个名为app的应用程序。

自动取款机

当转到:http://127.0.0.1:8000/app/profile/时,这是结果的一部分

app/views.py有以下配置文件代码:

代码语言:javascript
复制
# 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获得的,请参见:

代码语言:javascript
复制
subreddit = reddit.subreddit('redditdev')

print(subreddit.display_name)  # Output: redditdev

一旦它真正尝试进入Reddit并吸收数据,结果就是:

代码语言:javascript
复制
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

https://pypi.python.org/pypi/praw

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-01 16:00:29

已修复。问题是:

代码语言:javascript
复制
username='username',
password='password',

把它取下来然后开始工作。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42535140

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档