Anu*_*TBE 5 cheerio angular angular6
我正在使用Angular 6和scraperjs.
在我的组件文件中,使用了示例中给出的代码
import { Component, OnInit } from '@angular/core';
import scraperjs from 'scraperjs';
@Component({
selector: 'app-express',
templateUrl: './express.component.html',
styleUrls: ['./express.component.css']
})
export class ExpressComponent implements OnInit {
constructor() { }
ngOnInit() {
this.aliExpress();
}
aliExpress() {
console.log('loaded ali express');
scrapperjs.StaticScraper.create('https://news.ycombinator.com')
.scrape(function ($) {
return $('.title a').map(function () {
return $(this).text();
}).get();
}).then(function (news) {
console.log(news);
});
}
}
Run Code Online (Sandbox Code Playgroud)
但它给出了错误
Failed to compile.
./node_modules/cheerio/index.js
Module not found: Error: Can't resolve './package' in '/home/user/code/angular/ali-express/node_modules/cheerio'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1294 次 |
| 最近记录: |