Angular http.get() url 作为原始 HTML

Aar*_*ing 2 angular angular-httpclient

我正在为一个任务创建一个站点,我想在其中动态加载一些数据。问题是,数据只是来自网站,没有 API 或任何东西。有什么方法可以在 angular 中使用 http.get 将整个网站作为原始 HTML 提取,然后我可以解析信息吗?

谢谢

Rea*_*lar 5

您可以将responseTypeto设置"text"为以字符串形式获取响应。

this.httpClient.get(url, {responseType: "text"})
Run Code Online (Sandbox Code Playgroud)

参见重载方法#3:

https://angular.io/api/common/http/HttpClient#get

注意:GET 的跨域请求受 CORS 约束