首页 > 解决方案 > 如何从网站获取html数据

问题描述

<noscript><strong>Javascript is enabled in your web browser on a specific site while implementing web crawling. If you disable JavaScript, this text will change.</strong></noscript>

我检查了是否添加了相同的标签。对于包含这个标签的站点,即使你用axios请求获取站点url,html值也不会完全进来。我该如何解决这个问题?(我用谷歌翻译。对不起。)

https://vibe.naver.com/chart/total <= 这个网站

标签: javascripthtmlnode.jsaxios

解决方案


真的不知道你有什么问题,但这段代码应该可以工作

       const axios = require('axios');
       axios.get("https://vibe.naver.com/chart/total").then(html => {
        console.log(html.data)
})

使用节点获取的方法

const fetch = require("node-fetch");
fetch("https://vibe.naver.com/chart/total").then(result => result.text()).then(result => {
console.log(result)
})

如果您没有获得整个网站,则可能是反机器人措施


推荐阅读