Comments (2)
Of course! You can do that by the following way.
import os
import PyPtt
if __name__ == '__main__':
ptt_bot = PyPtt.API()
try:
ptt_bot.login(
os.environ['PTT1_ID'],
os.environ['PTT1_PW'])
search = {
'board': 'Minecraft',
'search_type': PyPtt.SearchType.AUTHOR,
'search_condition': 'haidai',
}
newest_index = ptt_bot.get_newest_index(index_type=PyPtt.NewIndex.BOARD, **search)
print(f'Newest index: {newest_index}')
for i in range(1, newest_index + 1):
post = ptt_bot.get_post(index=i, query=True, **search)
author = post.get('author')
aid = post.get('aid')
title = post.get('title')
print(f'{author} {aid} {title}')
except Exception as e:
print(e)
finally:
ptt_bot.logout()
The script output.
[01.01 18:55:35][PyPtt] PyPtt v 1.0.11 由 CodingMan 開發
[01.01 18:55:35][PyPtt] PyPtt [初始化]
[01.01 18:55:35][PyPtt] 設定連線模式 [WebSocket]
[01.01 18:55:35][PyPtt] 設定語言模組 [繁體中文]
[01.01 18:55:35][PyPtt] 設定連線主機 [批踢踢]
[01.01 18:55:35][PyPtt] 確認最新版本
[01.01 18:55:35][PyPtt] 成功
[01.01 18:55:35][PyPtt] 正在執行最新版本 [1.0.11]
[01.01 18:55:35][PyPtt] 登入帳號 [CodingMan]
[01.01 18:55:38][PyPtt] 成功
Newest index: 71
haidai 1HkUgMA1 [討論] amidst沒辦法用怎麼解決?
haidai 1Ju1V7ne [討論] 玩minecraft玩到記憶體壞掉?
haidai 1KWn5kJc R: [請問] Hamachi無法連接logmein登入服務
haidai 1LFFY9DC [情報] google cloud 架設 minecraft 伺服器(en)
haidai 1MQta_qp [徵選] 徵選版主 haidai
haidai 1MSNHzKQ [公告] 新官上任...
haidai 1MSUzrlN [討論] 置底閑聊區
haidai 1MTOQnYT [討論] 關於翻譯文獎勵辦法(禁止Re)
haidai 1MaxqYF5 [討論] 建築比賽人數粗估 找到伺服器啦~
haidai 1MdtgqnX [公告] 精華區小版主招募!!!!
haidai 1MgVYjs0 [公告] 二月翻譯文獎勵辦法
haidai 1MrOuqbq Fw: [閒聊] 有女孩也會玩Minecraft的嗎
haidai 1Ms3Vw7y [討論] 關於二月翻譯獎勵資格認定
haidai 1N0eUhlI [討論] 版務相關事項(板規修訂等等)
haidai 1N8BZLv4 [公告] 板規修訂
haidai 1N9t9D-_ R: [公告] 板規修訂
haidai 1NBqTE-p [公告] 新板規最後一次公告 生效日期5/14
haidai 1NFIvBC2 Fw: [詐騙] 年關將近,小心詐騙 (1/25更新)
haidai 1NHlJhn0 [分享] 歪國人的四柱生存,後半段這創造力...
haidai 1NQBLy2p [公告] 即日起禁止任何交易文
haidai 1NTKdmWm [板務] 關於文章分類與違規追溯期
haidai 1NUA7wDf [公告] 板規修正,開放閒聊分類
haidai 1NbZshOR [公告] k9531001水桶14天
haidai 1Nc32Ko5 [閒聊] 中秋節系列活動相關討論
haidai 1Ne_xNjV [公告] 中秋節活動相關細節投票中,大寫V投票
haidai 1NiITZqH [公告] 中秋節系列活動相關討論
haidai 1NjkcZBB [公告] 中秋節系列活動壓力測試
haidai 1NkkLK_M [公告] 中秋節活動已通過P幣審核,公布主題
haidai 1NoR9Nqa [公告] mint5419水桶14天
haidai 1NsNQ_l5 [公告] 中秋節活動開跑
haidai 1NsNvz85 [活動] 中秋活動參賽 主題:XXXXXXXXXX
haidai 1Nt1fxcc [公告] 中秋節活動截止
haidai 1NtCqbTM [公告] 中秋活動票選開始
haidai 1NuIABSY [公告] 中秋節活動票選結果
haidai 1NyyCXUr R: [公告] 中秋節活動票選結果
haidai 1O1EOO5- [版務] 版規修訂第二波
haidai 1O3N21fw [版規] 最新板規 2016/10/24版 發文前詳閱
haidai 1O3qIUil [版務] 相關遊戲放寬限制事宜
haidai 1O3s3ari [閒聊] Top 20 Core PC Games US&EU
haidai 1OA1YPO8 [版務] 相關遊戲放寬限制事宜(總結)
haidai 1OCkgyDF [分享] 能上網和打視訊通話的手機(中文翻譯)
haidai 1OEij0sg [版規] 最新板規 2016/11/27版 發文前詳閱
haidai 1OePrCpw R: [分享] minecraft動態市場經濟 - dynmarket
haidai 1Oxu8-vI Fw: [公告] 4/16 停機公告
haidai 1P1SYJsJ [自介] 沒想到版主竟然沒有自介過 haidai
haidai 1P4yITna [公告] 精華區小板主徵求 月薪10kp幣
haidai 1P9jG7H- [公告] justlonly水桶一天
haidai 1PEhN-ko [公告] 新版本徵文活動--新手入門文章(更新)
haidai 1PLnrRVf [分享] 量子特工║伊澤拉爾:絕冬城║ 第一住宅區
haidai 1PLp6zHE [公告] 徵文活動彙整
haidai 1Pg04z1h Fw: [情報] 26th 小天使招考(8/28~9/10)
haidai 1PpsDAMI [分享] 2017亞洲首創公益電玩接力賽 Minecraft
haidai 1Pu1iA6P [公告] ilovecim 水桶十四天
haidai 1Q0HcHy- [公告] Minecraft 板 開始舉辦樂透!
haidai 1Q4u6UHS Fw: [公告] 11/21 停機公告
haidai 1QJj4H1C [公告] 2018年度版規意見徵集
haidai 1QyxR_w5 [實況] 版主不務正業實況沈浸工程(收)
haidai 1R2044w4 [分享] 土豪家的波音747爆改 (論數學重要性)
haidai 1R6ojc88 R: [問題] 想第一次玩Hypixel就顯示被ban
haidai 1RE4RutS [公告] jokeless 水桶十四天
haidai 1RO6ie4N Fw: [公告] 8/4 停機公告
haidai 1ReyQSv5 [公告] Minecraft 板 開始舉辦樂透! 投注前請詳閱
haidai 1S2yIjyA [情報] 故事模式在netflix上線
haidai 1TPU6DsQ [版務] 現階段看板目標與後續期望目標
haidai 1TRy5OOS [分享] 麥塊中的G8事
haidai 1UpT7hg8 [版務] 版規修訂公聽
haidai 1VhwQldu [情報] minecraft桌遊台灣代理預購
haidai 1VxQXBBw R: [問題] 架了server 下一步??
haidai 1Wk8B1ol R: [問題] 修補附魔在鑽石鎬
haidai 1WmsVNMg [伺服] google cloud測試用伺服器1.17
haidai 1XmTWIk6 [公告] 新任見習版主上任 jasmine3471
[01.01 18:55:41][PyPtt] 登出
[01.01 18:55:41][PyPtt] 成功
from pyptt.
Hi @yaoshihyu2023 , does this answer help you?
from pyptt.
Related Issues (20)
- 新手問題(AttributeError: module 'PyPtt' has no attribute 'API') HOT 1
- 板主名單有特殊字元出錯 HOT 2
- 請問有辦法取得一定範圍的文章嗎? HOT 4
- 使用get_newest_index取book看板的newest_index不是最新的 HOT 3
- get_newest_index 用 search_list 搜特定關鍵字異常 HOT 7
- 特定簽名檔會造成使用寄信功能後無法正常使用其他功能 HOT 2
- SingleLog 是否為必須的依賴? HOT 3
- 在抓我的最愛的時候,碰到分隔線就不繼續往下抓看板了 HOT 1
- 使用 PyPtt 的各位,有沒有意願加入 AI Labs
- 功能新增:匿名發文功能 HOT 8
- ConnectError: 連線失敗 HOT 3
- Failed to connect to PTT while PTT2 is Good HOT 1
- 編輯紅包袋 HOT 3
- code execution backdoor
- get_mail function will raise exception when mail without proper title HOT 3
- get_newest_index回傳2,但只有一篇文章(aid相同) HOT 1
- 新增功能;樂透功能 HOT 3
- comment 功能異常 HOT 1
- comment 功能異常 HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyptt.