Skip to content

Commit

Permalink
知乎数据
Browse files Browse the repository at this point in the history
  • Loading branch information
taoey committed Oct 14, 2023
1 parent 69a127b commit f9427d0
Show file tree
Hide file tree
Showing 7 changed files with 426 additions and 0 deletions.
68 changes: 68 additions & 0 deletions zhihu_hot/data/csv_view.html
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>
49 changes: 49 additions & 0 deletions zhihu_hot/data/csv_view_common.html
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>
Loading

0 comments on commit f9427d0

Please sign in to comment.