簡體   English   中英

PRAW / PYTHON,如何在.comments函數中修復400 HTTP響應?

[英]PRAW/PYTHON, how to fix 400 HTTP Response in .comments function?

我正在嘗試抓取Reddit評論,並且在向Reddit發送請求方面遇到困難。 似乎在我的短腳本中的某處發生了一些錯誤的語法。 誰能發現它?

我嘗試了和不使用redirect_uri。 在我的Reddit應用頁面下,它說我的應用已被授權。 我還嘗試將user_agent名稱更改為我的用戶名以外的其他名稱,但這仍然無法正常工作。 我不確定要提供什么其他信息。

import praw #Python Reddit API Wrapper

reddit = praw.Reddit(client_id='ID', \ #the personal number
                     client_secret='SECRET', \ #the secret number
                     user_agent='Username', \ #Identical to username
                     username='Username', \ #Identical to user_agent
                     password='PW', \ 
                     redirect_uri='http://localhost:8080')

#confirm connection:
print(reddit.user.me()) # this works and returns my Username

submission = reddit.submission("https://www.reddit.com/r/funny/comments/ch6oz0/amasian/")
submission.comments #this fails and returns:

  File "/lib/python3.6/site-packages/prawcore/sessions.py", line 130, in _request_with_retries
    raise self.STATUS_EXCEPTIONS[response.status_code](response)

BadRequest: received 400 HTTP response
help(reddit.submission)
Help on method submission in module praw.reddit:

submission(id=None, url=None) method of praw.reddit.Reddit instance
    Return a lazy instance of :class:`~.Submission`.

    :param id: A reddit base36 submission ID, e.g., ``2gmzqe``.
    :param url: A URL supported by
        :meth:`~praw.models.Submission.id_from_url`.`.

    Either ``id`` or ``url`` can be provided, but not both.

Submit()認為我正在輸入ID,因為未指定url =''。

伙計們,不能太過哀悼,結案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM