KOMI
<!DOCTYPE html><html lang="zh-Hant">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Komica1 文章列表</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f9f9f9;
margin: 0;
padding: 20px;
}
.article-list {
max-width: 100%;
margin: 0 auto;
background-color: #fff;
padding: 15px;
border-radius: 4px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.article-list h2 {
font-size: 20px;
margin-bottom: 10px;
}
.article-list ul {
list-style: none;
padding: 0;
}
.article-list ul li {
padding: 10px 0;
border-bottom: 1px solid #ddd;
}
.article-list ul li:last-child {
border-bottom: none;
}
.article-list a {
text-decoration: none;
color: #1a0dab;
}
.article-list a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="article-list">
<h2>最新文章</h2>
<ul id="articleList">
<!-- 文章列表将显示在这里 -->
</ul>
</div>
<script>
async function fetchArticles() {
try {
const response = await fetch('https://komica1.org/'); // 跨域请求可能会被阻止
const text = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(text, 'text/html');
const articles = doc.querySelectorAll('.post a'); // 修改选择器以匹配文章链接
const articleList = document.getElementById('articleList');
articles.forEach(article => {
const listItem = document.createElement('li');
const link = document.createElement('a');
link.href = article.href;
link.textContent = article.textContent;
listItem.appendChild(link);
articleList.appendChild(listItem);
});
} catch (error) {
console.error('抓取文章时发生错误:', error);
const articleList = document.getElementById('articleList');
articleList.innerHTML = '<li>无法抓取文章列表,请检查跨域设置或使用服务器端抓取。</li>';
}
}
fetchArticles();
</script>
</body>
</html>
頁:
[1]