modify scripts
This commit is contained in:
@ -189,7 +189,7 @@ def pase_chapter_list(soup, url):
|
|||||||
chap_data = []
|
chap_data = []
|
||||||
for chap in chap_list:
|
for chap in chap_list:
|
||||||
chap_title = chap.get_text().strip()
|
chap_title = chap.get_text().strip()
|
||||||
chap_link = f'{host_url}/{chap['href']}'
|
chap_link = f"{host_url}/{chap['href']}"
|
||||||
chap_id = utils.extract_page_num(chap_link)
|
chap_id = utils.extract_page_num(chap_link)
|
||||||
chap_data.append({'href': chap_link, 'title': chap_title, 'chapter_id': chap_id})
|
chap_data.append({'href': chap_link, 'title': chap_title, 'chapter_id': chap_id})
|
||||||
table_of_contents.append({'title': section_title, 'chapters': chap_data})
|
table_of_contents.append({'title': section_title, 'chapters': chap_data})
|
||||||
@ -250,7 +250,7 @@ def parse_chapter_page(soup, url):
|
|||||||
if next_div:
|
if next_div:
|
||||||
next_page_tag = next_div.find('a', href=True, title=re.compile(r'下一章'))
|
next_page_tag = next_div.find('a', href=True, title=re.compile(r'下一章'))
|
||||||
if next_page_tag:
|
if next_page_tag:
|
||||||
next_url = f'{host_url}/{next_page_tag['href']}' if next_page_tag['href'] else ''
|
next_url = f"{host_url}/{next_page_tag['href']}" if next_page_tag['href'] else ''
|
||||||
|
|
||||||
data = {'title': title, 'content_url': content_url, 'table_of_contents': table_of_contents}
|
data = {'title': title, 'content_url': content_url, 'table_of_contents': table_of_contents}
|
||||||
return data, next_url
|
return data, next_url
|
||||||
|
|||||||
Reference in New Issue
Block a user