简体   繁体   English

AngularJS应用程序中的Web抓取

[英]Web scraping in AngularJS application

I have an AngularJS application which currently uses http.get to get JSON data from an API. 我有一个AngularJS应用程序,当前使用http.get从API获取JSON数据。 This works great. 这很好。

I'm wondering if I can pass a static webpage URL , and scrape the results using the response from http.get ? 我想知道是否可以传递静态网页URL并使用http.get的响应http.get

I've seen tutorials on web scraping with Node and JavaScript libraries like ScraperJS , but I haven't been able to successfully use these in an Angular (client-side) application. 我看过有关使用Node和JavaScript库(例如ScraperJS)进行Web抓取的教程,但是我无法在Angular(客户端)应用程序中成功使用它们。 Is there anyway to use a JavaScript web scraping library in Angular? 无论如何,在Angular中可以使用JavaScript网络抓取库吗?

There is no direct way to do so because this has nothing to do with Angular at all. 没有直接的方法可以这样做,因为这与Angular完全无关。 Client-side JavaScript is just that. 客户端JavaScript就是这样。 It runs on the client. 它在客户端上运行。 What you need to do involves making an HTTP call for request URL and retrieving the HTML from a site, then parsing that HTML for various meta-data. 您需要做的事情包括对请求URL进行HTTP调用并从站点检索HTML,然后解析该HTML以获取各种元数据。 That needs to be done via a server-side call to the site to load the data from the remote site. 这需要通过对站点的服务器端调用来完成,以从远程站点加载数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM