get_newest_index¶
- PyPtt.API.get_newest_index(self, index_type: NewIndex, board: str | None = None, search_type: SearchType | None = None, search_condition: str | None = None, search_list: List[Tuple[Any, str]] | None = None) int
取得最新文章或信箱編號。
- 參數:
index_type (NewIndex) – 編號類型。
board (str) – 看板名稱。
search_list (List[Tuple[Any | str]]) – 搜尋清單。
- 回傳:
int,最新文章或信箱編號。
- 引發:
RequireLogin – 需要登入。
NoSuchBoard – 看板不存在。
取得最新看板編號:
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() search_list = [(PyPtt.SearchType.KEYWORD, 'PyPtt')] try: # .. login .. newest_index = ptt_bot.get_newest_index(PyPtt.NewIndex.BOARD, 'Python', search_list=search_list) # .. 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()