lewisdonovan / google-news-scraper

Lightweight scraper for Google News
Other
243 stars 62 forks source link

i try to use but i have error #62

Open pingplass123 opened 3 weeks ago

pingplass123 commented 3 weeks ago
TypeError: (0 , google_news_scraper_1.default) is not a function

and this is my code

      import googleNewsScraper from 'google-news-scraper';

      const articles = await googleNewsScraper({ searchTerm: "The Oscars" }); 
      return articles;

by the i use nestjs typescript

pingplass123 commented 3 weeks ago

any solution for this issue? @lewisdonovan

lewisdonovan commented 3 weeks ago

I can't replicate your issue. I've created a minimum example in this repo: https://github.com/lewisdonovan/gns-example If you pull this repo and run it locally (see the instructions in the README file) does it work for you?

If so, there's likely something wrong with your setup. Providing a minimum example of your non-working code will help me to identify the issue for you.

If the minimum example I've provided doesn't work, then it's likely an incompatibility with your environment. If you can share details of what system/server environment you're running this on, I can help you to find the issue.

pingplass123 commented 3 weeks ago

this repo: https://github.com/lewisdonovan/gns-example is working but my project is using nestjs so i use this for api getting news and then response back

lewisdonovan commented 3 weeks ago

Ok, great that we've narrowed that down. So now if you can provide a minimum reproducible example?

Providing a minimum example of your non-working code will help me to identify the issue for you.

☝️

flitzcore commented 6 days ago

Hi, I wonder if you have solved this yet. I use nest js and stumble into the same problem. For me it's because how NestJs or Ts look for type. Converting: import googleNewsScraper from 'google-news-scraper';

into

const googleNewsScraper = require('google-news-scraper');

solved the issue for me