最近在学习nodejs,在尝试写一个简单的爬虫,用http.get(url..)的形式,爬取'http://segmentfault.com/'的问题列表,但是,好像nodejs不支持htpps的网页?报错如下:Error: Protocol "https:" not supported. Expected "http:"at new ClientRequest (_http_client.js:54:11)at Object.exports.request (http.js:31:10)at Object.exports.get (http.js:35:21)at Object.<anonymous> (E:\1Javascript\node-study\bug\crawler.js:24:6)at Module._compile (module.js:570:32)at Object.Module._extensions..js (module.js:579:10)at Module.load (module.js:487:32)at tryModuleLoad (module.js:446:12)at Function.Module._load (module.js:438:3)at Module.runMain (module.js:604:10)
1 回答
慕盖茨4494581
TA贡献1850条经验 获得超11个赞
没有代码,不过我猜你用错了模块
const http = require('http')
const https = require('https') // https用这个
添加回答
举报
0/150
提交
取消