获取网页的HTML来源 [英] Get Html source of Webpage

查看:66
本文介绍了获取网页的HTML来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友.

我有一个网页(my.aspx).
在该页面中,我在div标签内有一些控件,而在div标签外有一些控件.
现在我想要使用JAVASCRIPT在[B] inside [/B] div标签中的那些控件的html源.

我该怎么做.

我得到了可以获取整个页面来源的代码.该代码是用JAVASCRIPT编写的.

Hello friends.

I have a webpage (my.aspx).
In that page i have some controls inside div tag and some controls outside div tag.
Now i want the html source of those controls which are [B]inside[/B] div tag using JAVASCRIPT.

How can i do this.

I got the code with which i can get the source of whole page. the code is written in JAVASCRIPT.

 function getHtml()
{
   var srch = document.documentElement.innerHTML;
}

推荐答案

您只需要扩展一点即可.

如果您的div为:

You just need to extend that a wee bit.

If you have a div as:

<div id="divToFind"></div>



您可以使用:



You could use:

var srch = document.getElementById(''divToFind'').innerHTML;



如果您有jquery,那就更容易了:



if you had jquery it''s even easier:

var srch =


get(''divToFind'').innerHTML;
get(''divToFind'').innerHTML;



那应该会让您入门.



That should get you started.


这篇关于获取网页的HTML来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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