get_newest_index#

PyPtt.API.get_newest_index(self, index_type: NewIndex, board: Optional[str] = None, search_type: Optional[SearchType] = None, search_condition: Optional[str] = None, search_list: Optional[List[str]] = None) int

取得最新文章或信箱編號。

參數:
  • index_type (NewIndex) – 編號類型。

  • board (str) – 看板名稱。

  • search_type (SearchType) –

  • search_condition (str) – 搜尋條件。

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

回傳:

int,最新文章或信箱編號。

引發:

取得最新看板編號:

import PyPtt

ptt_bot = PyPtt.API()

# get newest index of board
try:
    # .. login ..
    newest_index = ptt_bot.get_newest_index(PyPtt.NewIndex.BOARD, 'Python')
    # .. do something ..
finally:
    ptt_bot.logout()

取得最新信箱編號:

import PyPtt

ptt_bot = PyPtt.API()

# get newest index of mail
try:
    # .. login ..
    newest_index = ptt_bot.get_newest_index(PyPtt.NewIndex.MAIL)
    # .. do something ..
finally:
    ptt_bot.logout()

參考 搜尋編號種類取得文章