Skip to content

Commit

Permalink
请求头补充
Browse files Browse the repository at this point in the history
  • Loading branch information
xiajieqiong committed Apr 29, 2024
1 parent a8d5817 commit 2a825de
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/crawl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ import prettierOptions from '../.prettierrc.json';
import ora from 'ora';

function request(url: string) {
return Axios.get(url);
return Axios.get(url, {
headers: {
'User-Agent':
'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1',
Accept:
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
'Accept-Encoding': 'gzip, deflate, br, zstd',
},
});
}

interface NetInfo {
Expand Down Expand Up @@ -158,6 +167,7 @@ program.option('-u, --url <url>').action(async (params) => {
console.log('解析成功!');
} catch (error: any) {
console.log('解析出错:', error.message);
console.log(error);
} finally {
spinner && spinner.stop();
}
Expand Down

0 comments on commit 2a825de

Please sign in to comment.