-
Notifications
You must be signed in to change notification settings - Fork 185
Open
Description
I want to use it in Angular 6 application.
In my component file, I have tried following code with your sample code.
import { Component, OnInit } from '@angular/core';
@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');
var scraperjs = require('scraperjs');
scraperjs.StaticScraper.create('https://news.ycombinator.com')
.scrape(function ($) {
return $('.title a').map(function () {
return $(this).text();
}).get();
}).then(function (news) {
console.log(news);
});
}
}
I also tried with
import {scraperjs} from 'scraperjs';
and
import scraperjs from 'scraperjs`;
But it is giving error as
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'
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels