get_post#

PyPtt.API.get_post(self, board: str, aid: Optional[str] = None, index: int = 0, search_type: SearchType = 'NOPE', search_condition: Optional[str] = None, search_list: Optional[List[str]] = None, query: bool = False) Dict

取得文章。

參數:
  • board (str) – 看板名稱。

  • aid (str) – 文章編號。

  • index – 文章編號。

  • search_type (SearchType) – 搜尋類型。

  • search_condition (str) – 搜尋條件。

  • search_list (List[str]) – 搜尋清單。

  • query (bool) – 是否為查詢模式。

回傳:

Dict,文章內容。詳見 PostField

引發:

使用 AID 範例:

import PyPtt

ptt_bot = PyPtt.API()
try:
    # .. login ..
    post_info = ptt_bot.get_post('Python', aid='1TJH_XY0')
    # .. do something ..
finally:
    ptt_bot.logout()

使用 index 範例:

import PyPtt

ptt_bot = PyPtt.API()
try:
    # .. login ..
    post_info = ptt_bot.get_post('Python', index=1)
    # .. do something ..
finally:
    ptt_bot.logout()
更多範例參考 取得文章