HTMLAgilitypack通过Ajax调用读取html页面信息 [英] HTMLAgilitypack read html page info with ajax calls

查看:65
本文介绍了HTMLAgilitypack通过Ajax调用读取html页面信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HtmlAgilitypack读取特定URL的特定html元素.我面临的问题是AJAX请求填充了html标记内容之一.那我怎么读呢?

I am using HtmlAgilitypack for reading specific html elements of a specific url. The problem I am facing is one of the html tag contents are filled by AJAX requests. So how can I read this ?

<div id="priceInfo"></div>

我用来读取网址的代码是

Code I used to read the url is

HtmlWeb _htmlWeb = new HtmlWeb();
HtmlAgilityPack.HtmlDocument _webDoc = _htmlWeb.Load(webUrl);
// HtmlNodeCollection _priceNode =  Gets the node with id priceInfo

此div的内容由ajax请求填充,我想在其填充后读取此DIv的内容.我该怎么做

The contents of this div is filled by a ajax request and i want to read the contents of this DIv after its getting filled. How can i do that

推荐答案

HtmlAgilityPack将在服务器端使用.根据您的陈述,您正在尝试在客户端而不是在服务器端声明一个值.

HtmlAgilityPack is to be used at server side. from what you stating, you are trying to assert a value at client side, not at the server side.

一旦ajax调用完成,您应该考虑使用jquery/javascript.

you should look into using jquery/javascript once the ajax call is done.

ajax ({ ....
  .done(...) {
    // handling the return result...
    alert($("#yourHtmlId").val()); // show one of your html tag value attribute.
  }   
})

http://api.jquery.com/jQuery.ajax/

这篇关于HTMLAgilitypack通过Ajax调用读取html页面信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆