Open anuj9196 opened 6 years ago
I want to use it in Angular 6 application.
Angular 6
In my component file, I have tried following code with your sample code.
component
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'
I want to use it in
Angular 6
application.In my
component
file, I have tried following code with your sample code.I also tried with
and
But it is giving error as