This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| from bs4 import BeautifulSoup | |
| import time | |
| import os | |
| def sanitize_filename(filename): | |
| """Removes characters that are invalid for filenames.""" | |
| return "".join(c for c in filename if c.isalnum() or c in (' ', '-', '_')).rstrip() | |
| def scrape_novel(novel_code): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import re | |
| import sys | |
| from tqdm import tqdm | |
| from html import unescape | |
| from bs4 import BeautifulSoup | |
| def strip_html_tags(html: str) -> str: | |
| """Remove HTML tags for plain text extraction.""" | |
| soup = BeautifulSoup(html, "html.parser") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let htmlString = document.body.innerHTML | |
| const parser = new DOMParser(); | |
| const doc = parser.parseFromString(htmlString, 'text/html'); | |
| const messages = []; | |
| const divs = doc.querySelectorAll('.group.relative.max-w-3xl.min-max-w-3xl.m-auto.w-full.p-2'); | |
| divs.forEach(div => { | |
| const nameElement = div.querySelector('.text-small'); | |
| if (nameElement) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function extractAndDownloadAllChapters() { | |
| // Find all containers that hold chapter text | |
| const chapterContainers = document.querySelectorAll('.cha-words'); | |
| // Initialize an array to hold all chapter texts | |
| let allChaptersText = []; | |
| // Iterate over each chapter container | |
| chapterContainers.forEach(container => { | |
| // Get all paragraph elements within the container |