javascript - 为什么 node-fetch 在此站点上不起作用?
问题描述
我正在尝试抓取网站“ https://shmoti.com
”。但不幸的是,node-fetch 的fetch
方法根本没有得到响应。它适用于其他网站。
这是我的代码
const fetch = require("node-fetch")
fetch('https://shmoti.com', options = {headers : {'User-Agent' : 'Mozilla/5.0'}}).then(res=>res.text()).then(res=>console.log(res))
解决响应对象的第一个承诺一直处于挂起状态。
我什至尝试过拥有一个 User-Agent 。我设置了 60 秒的超时时间。scrapy
我可以使用python 中的库成功抓取该站点,但使用fetch
方法,它总是超时。
为什么会这样?我怎样才能解决这个问题 ?
我也可以 ping 该网站并在我的浏览器中打开它,但只有从节点获取不起作用。
解决方案
推荐阅读
- azure-devops - Azure DevOps - 计费可见性 + 详细信息
- delphi - E2362 无法访问受保护的符号 TControl.Color 我该如何解决?
- android - 在我的 React Native 应用程序中实现 UsageStats 模块时遇到问题
- android - 如何检查图标是否显示在android测试的输入字段中
- ios - Pod lib lint 对于 xcframework 失败
- excel - 将excel表格中的数据显示到excel表格中的列表框
- c++ - 使用 std::unique ptr 的二叉搜索树
- telegram - 如何通过电报向我只有聊天 ID 的人发送消息?
- ruby - 如何运行厨师刀插件?
- php - 致命错误:无法突然重新声明 PHPMailerAutoload()