使用Praw 4.4.0在Python 2.7虛擬環境中本地構建Django 1.8 Web應用程序。錯誤:PYTHON DJANGO PRAW REDDIT-API
該項目被稱爲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的名字被打印。 大。
好吧,不是那麼好。這是寫在代碼,所以它不是從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/Mar/2017 14:50:02]"GET /app/profile/ HTTP/1.1" 500 93288
使用Debug mode = True
,可以看到頁面如下:
問題:不知何故,Reddit不喜歡我的登錄。
他們如何開始喜歡我,讓我打印數據?
我能做些什麼更好?
謝謝您的支持
\\\\\一些有用的鏈接////////
http://praw.readthedocs.io/en/latest/getting_started/quick_start.html
https://pypi.python.org/pypi/praw