javascript - 如何从网站获取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值也不会完全进来。我该如何解决这个问题?(我用谷歌翻译。对不起。)
解决方案
真的不知道你有什么问题,但这段代码应该可以工作
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)
})
如果您没有获得整个网站,则可能是反机器人措施
推荐阅读
- eclipse - PyDev Python简单的hello world程序不断终止而不向控制台返回任何内容
- c - C - 为什么 * 符号出现在之前和之后的内存分配
- c# - 以编程方式将变量插入 string.format ( C# )
- haskell - 通过 DeriveAnyClass 派生的行为与 emply 实例声明不同
- c# - Unity:此机器不支持语音识别
- html - 将图像从 json 对象加载到 html 网页上
- python - 为 windows 编译搅拌器时出错 - 找不到 OSL
- deep-learning - Pytorch - 使用 LSTM 网络时尺寸不正确
- firebase - 使用 Firebase 的应用程序可以在手机上运行,但在 Genymotion 中不起作用
- vb.net - VB.NET Timer.Start() 循环无值