-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
426 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>CSV Viewer</title> | ||
<style> | ||
table { | ||
border-collapse: collapse; | ||
width: 100%; | ||
} | ||
th, td { | ||
border: 1px solid #dddddd; | ||
text-align: left; | ||
padding: 8px; | ||
} | ||
tr:nth-child(even) { | ||
background-color: #f2f2f2; | ||
} | ||
/* 设置第四列的宽度 */ | ||
td:nth-child(4) { | ||
width: 30%; /* 你可以根据需要调整宽度 */ | ||
} | ||
td:nth-child(6) { | ||
width: 55%; /* 你可以根据需要调整宽度 */ | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>zhihu-hot</h1> | ||
<table id="csvTable"> | ||
<!-- CSV data will be inserted here --> | ||
</table> | ||
<script> | ||
// Load and display CSV data | ||
fetch('output.csv') | ||
.then(response => response.text()) | ||
.then(data => { | ||
const rows = data.split('\n'); | ||
const table = document.getElementById('csvTable'); | ||
|
||
rows.forEach((row, rowIndex) => { | ||
const cells = row.split('|||'); | ||
const newRow = document.createElement('tr'); | ||
|
||
cells.forEach((cell, cellIndex) => { | ||
const newCell = document.createElement('td'); | ||
|
||
// Check if the cell is in the "url" column (index 3) | ||
if (cellIndex === 3 && rowIndex !== 0) { | ||
// Create a link and attach it to the "title" cell | ||
const link = document.createElement('a'); | ||
link.href = cell; | ||
link.textContent = cells[2]; // Assume title is in the 3rd column (index 2) | ||
newCell.appendChild(link); | ||
} else if (cellIndex !== 0 && cellIndex !== 1 && cellIndex !== 2) { | ||
// Hide the 1st and 2nd columns, display others | ||
newCell.textContent = cell; | ||
} | ||
|
||
newRow.appendChild(newCell); | ||
}); | ||
|
||
table.appendChild(newRow); | ||
}); | ||
}) | ||
.catch(error => console.error('Error loading CSV:', error)); | ||
</script> | ||
</body> | ||
</html> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>CSV Viewer</title> | ||
<style> | ||
table { | ||
border-collapse: collapse; | ||
width: 100%; | ||
} | ||
th, td { | ||
border: 1px solid #dddddd; | ||
text-align: left; | ||
padding: 8px; | ||
} | ||
tr:nth-child(even) { | ||
background-color: #f2f2f2; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>zhihu-hot</h1> | ||
<table id="zhihu"> | ||
<!-- CSV data will be inserted here --> | ||
</table> | ||
<script> | ||
// Load and display CSV data | ||
fetch('output.csv') | ||
.then(response => response.text()) | ||
.then(data => { | ||
const rows = data.split('\n'); | ||
const table = document.getElementById('zhihu'); | ||
|
||
rows.forEach(row => { | ||
const cells = row.split('|||'); | ||
const newRow = document.createElement('tr'); | ||
|
||
cells.forEach(cell => { | ||
const newCell = document.createElement('td'); | ||
newCell.textContent = cell; | ||
newRow.appendChild(newCell); | ||
}); | ||
|
||
table.appendChild(newRow); | ||
}); | ||
}) | ||
.catch(error => console.error('Error loading CSV:', error)); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.