jeffeux's picture
Add application file
21e639d
from PyPtt import PTT
ptt_bot = PTT.API()
ptt_bot.login('jeffchen111', 'ntuee111')
def cc(RESRES):
def crawl_handler(post_info):
if post_info.delete_status != PTT.data_type.post_delete_status.NOT_DELETED:
if post_info.delete_status == PTT.data_type.post_delete_status.MODERATOR:
# print(f"[板主刪除][{post_info.author}]")
pass
elif post_info.delete_status == PTT.data_type.post_delete_status.AUTHOR:
# print(f"[作者刪除][{post_info.author}]")
pass
elif post_info.delete_status == PTT.data_type.post_delete_status.UNKNOWN:
# print(f"[不明刪除]")
pass
return
# print(f"[{post_info.aid}][{post_info.title}]")
# return post_info
PP = dict(
aid=post_info.aid,
index=post_info.index,
web_url=post_info.web_url,
title=post_info.title,
)
RESRES.append(PP)
return crawl_handler
boardname = "Gossiping"
newest = ptt_bot.get_newest_index(PTT.data_type.index_type.BBS, boardname)
RESRES = []
error_post_list, del_post_list = ptt_bot.crawl_board(
PTT.data_type.crawl_type.BBS,
# crawl_handler,
cc(RESRES),
boardname,
start_index=newest - 1000 * 2,
end_index=newest, # - 100 * 2,
# Optional
query=True,
)