Skip to content

Commit

Permalink
add local verification for current title
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrtye committed Feb 28, 2024
1 parent afcb06b commit c613605
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions novel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ def start_health_server():
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.6167.8 Safari/537.36"
}


def get_book_title(url, proxy=None):
html = requests.get(
url,
headers=headers,
proxies=proxy,
)
html.encoding = "gbk"
tree = etree.HTML(html.text, parser=None)

div_element = tree.xpath('//div[contains(@class, "qustime")]')[0]
span_element = div_element.xpath("./ul/li[1]/a/span")[0]
return span_element.text


try:
while True:
for index in range(len(proxies)):
Expand All @@ -141,22 +156,15 @@ def start_health_server():

try:
url = f"https://www.69xinshu.com/book/{books[i][0]}.htm"
html = requests.get(
url,
headers=headers,
proxies=proxy,
)
html.encoding = "gbk"
tree = etree.HTML(html.text, parser=None)

div_element = tree.xpath('//div[contains(@class, "qustime")]')[0]
span_element = div_element.xpath("./ul/li[1]/a/span")[0]
title = span_element.text
title = get_book_title(url, proxy)

if title != titles.get(books[i][1]):
if title == titles.get(books[i][1] + "previous"):
break

if title != get_book_title(url):
break

if titles.get(books[i][1]) is not None:
bot.send_message(
TELEBOT_USER_ID,
Expand Down

0 comments on commit c613605

Please sign in to comment.