从C#或AngularJS中的另一个URL获取数据(Getting Data from another URL in C# or AngularJS)

系统教程 行业动态 更新时间:2024-06-14 16:57:18
从C#或AngularJS中的另一个URL获取数据(Getting Data from another URL in C# or AngularJS)

我需要来自另一个Hadoop API URL的数据。 但是我只能得到没有数据的HTML源代码。 我正在使用下面的代码。

using (var client = new WebClient()) { String downloadedString = client.DownloadString("http:........"); }

实际结果:

<tr><th> Configured Capacity:</th><td> *{Total|fmt_bytes}* </td></tr>

期望

<tr><th> Configured Capacity:</th><td> 55 </td></tr>

我需要55我的C#代码。

我的期望可能吗? 如果是这样,请指导我。

I need data from another Hadoop API URL. But I only get the HTML source code without the data. I am using the following code.

using (var client = new WebClient()) { String downloadedString = client.DownloadString("http:........"); }

Actual Result:

<tr><th> Configured Capacity:</th><td> *{Total|fmt_bytes}* </td></tr>

Expectation

<tr><th> Configured Capacity:</th><td> 55 </td></tr>

I need 55 in my c# code.

Is my expectation possible? If so, please guide me.

最满意答案

您看到的问题是您的C#客户端不运行Javascript,这是从Hadoop网络服务器将该值加载到占位符{Total|fmt_bytes}

也可以用cURL显示

$ curl -s http://hadoop-nn1:50070/dfshealth.html#tab-overview | grep Configured
  <tr><th> Configured Capacity:</th><td>{Total|fmt_bytes}</td></tr>
      <th>Configured Capacity</th>
 

所以这不是Hadoop问题。 这是你的WebClient ...你需要使用Selenum WebDriver或PhantomJS。

The issue you are seeing is that your C# client does not run Javascript, which is what is loading that value from the Hadoop webserver into the placeholder of {Total|fmt_bytes}

Also showable with cURL

$ curl -s http://hadoop-nn1:50070/dfshealth.html#tab-overview | grep Configured
  <tr><th> Configured Capacity:</th><td>{Total|fmt_bytes}</td></tr>
      <th>Configured Capacity</th>
 

So this is not a Hadoop problem. It's your WebClient... You need to use something like Selenum WebDriver or PhantomJS instead.

更多推荐

本文发布于:2023-04-12 20:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/44a42bea24157d71791a941b82718aae.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   AngularJS   URL   Data

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!