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`, { method: "POST", headers: headers, body: 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: match[2],
title: match[3]
});
}
console.log(JSON.stringify(results));
return 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 = /