Skip to content

Commit

Permalink
修正作者暱稱帶有換行字元的處理
Browse files Browse the repository at this point in the history
  • Loading branch information
Truth1987 committed Nov 27, 2018
1 parent 5f09571 commit 14a6013
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
24 changes: 9 additions & 15 deletions PTTLibrary/PTT.py
Original file line number Diff line number Diff line change
Expand Up @@ -1859,39 +1859,33 @@ def __getPost(self, Board, PostID='', PostIndex=0, _ConnectIndex=0, SearchType=0
sys.exit()

FirstPage = FirstPage[FirstPage.find('作者'):]
PostLineList = FirstPage.split('\n')

# if len(PostLineList) < 3:
# ErrCode = ErrorCode.ParseError
# self.__ErrorCode = ErrCode
# return ErrCode, None
# for line in PostLineList:
# print('Q', line)
# print(FirstPage)

Target = '作者 '
if Target in FirstPage:
PostAuthor = PostLineList[0]
PostAuthor = FirstPage
PostAuthor = PostAuthor[PostAuthor.find(Target) + len(Target):]
PostAuthor = PostAuthor[:PostAuthor.find(')') + 1]
PostAuthor = PostAuthor.rstrip()
PostAuthor = PostAuthor.strip()
else:
PostAuthor = ListAuthor

Target = '標題 '
if Target in FirstPage:
PostTitle = PostLineList[1]
PostTitle = FirstPage
PostTitle = PostTitle[PostTitle.find(Target) + len(Target):]
PostTitle = PostTitle[:PostTitle.find('\r')]
PostTitle = PostTitle.rstrip()
PostTitle = PostTitle[:PostTitle.find('\n 時間')]
PostTitle = PostTitle.strip()
else:
PostTitle = None

Target = '時間 '
if Target in FirstPage:
PostDate = PostLineList[2]
PostDate = FirstPage
PostDate = PostDate[PostDate.find(Target) + len(Target):]
PostDate = PostDate[:PostDate.find('\r')]
PostDate = PostDate.rstrip()
PostDate = PostDate[:PostDate.find('\n')]
PostDate = PostDate.strip()
else:
PostDate = None

Expand Down
2 changes: 1 addition & 1 deletion PTTLibrary/Version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Ver = '0.7.19'
Ver = '0.7.20'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

版本
-------------------
###### 0.7.19
###### 0.7.20

安裝
-------------------
Expand Down
6 changes: 3 additions & 3 deletions Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def GetPostDemo():

PTTBot.Log('取得 ' + Board + ' 板最新文章編號: ' + str(NewestIndex))
else:
NewestIndex = 79280
NewestIndex = 78516
PTTBot.Log('使用 ' + Board + ' 板文章編號: ' + str(NewestIndex))

for i in range(TryPost):
Expand Down Expand Up @@ -1040,11 +1040,11 @@ def findPostRrange(HowDayBefore, show=False):
sys.exit()

try:
findPostRrange(1)
# findPostRrange(1)
# PostDemo()
# PushDemo()
# GetNewestIndexDemo()
# GetPostDemo()
GetPostDemo()
# MailDemo()
# GetTimeDemo()
# GetMailDemo()
Expand Down

0 comments on commit 14a6013

Please sign in to comment.