diff --git a/rumanhua1/rumanhua.js b/rumanhua1/rumanhua.js new file mode 100644 index 0000000..52f557c --- /dev/null +++ b/rumanhua1/rumanhua.js @@ -0,0 +1,412 @@ +async function searchContent(keyword,page=0){ + const headers = { + "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", + "X-Requested-With": "XMLHttpRequest", + }; + const postData = `k=${encodeURIComponent(keyword)}`; + + const response = await fetch(`http://www.rumanhua1.com/s`, headers, "POST", postData ); + const html = await response.text(); + const results = []; + const regex = /
([^<]+)<\/p>[\s\S]*?
([^<]+)<\/p>/g;
+ let match;
+ while ((match = regex.exec(html)) !== null) {
+ results.push({
+ id: "http://www.rumanhua1.com" + match[1],
+ imageURL: "http://www.rumanhua1.com" + match[2],
+ title: match[3]
+ });
+ }
+ return JSON.stringify(results);
+}
+
+async function getContentData(url) {
+ function parseHtmlData(htmlContent) {
+ const tagsRegex = /标\s+签:\s*<\/span>\s*([\s\S]*?)状/;
+ const descRegex = / ([\s\S]+?)<\/p>/;
+ const tagsMatch = htmlContent.match(tagsRegex);
+ const descMatch = htmlContent.match(descRegex);
+
+
+ const tags = [];
+ if (tagsMatch && tagsMatch[1].trim()) {
+ tagsMatch[1].split(/[,,、]/).forEach(tag => {
+ const t = tag.trim();
+ if (t) tags.push(t);
+ });
+ }
+
+ return {
+ description: descMatch ? descMatch[1].replace(/\\n/g, ' ').replace(/\s+/g, ' ').trim() : "",
+ tags: tags
+ };
+ }
+
+ const response = await fetch(url);
+ const data = await response.text();
+ console.log(JSON.stringify(parseHtmlData(data)));
+ return parseHtmlData(data);
+}
+
+async function getChapters(url) {
+ function parseHtmlData(htmlContent) {
+ const chapterRegex = /