Skip to content

Commit e6a5da8

Browse files
committed
review: fetch v2ex hot data within browser context
1 parent 64fd1d2 commit e6a5da8

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

src/clis/v2ex/hot.yaml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@ args:
1212
description: Number of topics
1313

1414
pipeline:
15-
- navigate: https://www.v2ex.com/api/topics/hot.json
15+
- navigate: https://www.v2ex.com/
1616

1717
- evaluate: |
1818
(async () => {
19-
// 获取页面中的JSON数据
20-
const preElement = document.querySelector('pre');
21-
if (preElement) {
22-
const jsonText = preElement.textContent;
23-
const data = JSON.parse(jsonText);
24-
return data;
19+
const response = await fetch('/api/topics/hot.json', {
20+
credentials: 'include',
21+
headers: {
22+
accept: 'application/json, text/plain, */*',
23+
'x-requested-with': 'XMLHttpRequest',
24+
},
25+
});
26+
if (!response.ok) {
27+
throw new Error(`V2EX hot API request failed: ${response.status}`);
2528
}
26-
return [];
29+
return await response.json();
2730
})()
2831
2932
- map:

0 commit comments

Comments
 (0)