
28.02.2025, 17:29
|
|
Постоянный
Регистрация: 15.05.2024
Сообщений: 331
С нами:
1053082
Репутация:
48
|
|
Сообщение от nikusyaxxs
Почему если страница темы >1, то начинает некорректно выводить содержимое заголовка?
Решил это изменением логики(?) получения названия темы
Python:
Код:
def
get_thread
(
self
,
thread_id
:
int
)
:
request
=
self
.
session
.
get
(
f"{MAIN_URL}/threads/{thread_id}/page-1?_xfResponseType=json&_xfToken={self.token}"
)
.
json
(
)
if
request
[
'status'
]
==
'error'
:
return
None
if
request
.
get
(
'redirect'
)
is
not
None
:
return
self
.
get_thread
(
request
[
'redirect'
]
.
strip
(
MAIN_URL
)
.
split
(
'/'
)
[
content
=
unescape
(
request
[
'html'
]
[
'content'
]
)
content_h1
=
unescape
(
request
[
'html'
]
[
'h1'
]
)
content
=
BeautifulSoup
(
content
,
'lxml'
)
content_h1
=
BeautifulSoup
(
content_h1
,
'lxm
creator_id
=
content
.
find
(
'a'
,
{
'class'
:
'username'
}
)
try
:
creator
=
self
.
get_member
(
int
(
creator_id
[
'data-user-id'
]
)
)
except
:
creator
=
Member
(
self
,
int
(
creator_id
[
'data-user-id'
]
)
,
content
.
find
(
'a'
,
{
'class'
:
'username'
}
)
.
text
,
None
,
None
,
None
,
None
,
None
,
None
)
create_date
=
int
(
content
.
find
(
'time'
)
[
'data-time'
]
)
try
:
prefix
=
content_h1
.
find
(
'span'
,
{
'class'
:
'label'
}
)
.
text
title
=
content_h1
.
text
.
strip
(
)
.
replace
(
prefix
,
""
)
.
strip
(
)
|
|
|