javascript - get a html element from another website (XSS) - Stack Overflow

How can I get a html element from another website directly into my site (not using an iframe).For Examp

How can I get a html element from another website directly into my site (not using an iframe).

For Example:

A page on another website has the following code (and nothing else);

<p>example text</p>

how can I get this into my website to be able to edit it. I can't directly copy the code because I want the code on my site to change in conjunction to the other site.

How can I get a html element from another website directly into my site (not using an iframe).

For Example:

A page on another website has the following code (and nothing else);

<p>example text</p>

how can I get this into my website to be able to edit it. I can't directly copy the code because I want the code on my site to change in conjunction to the other site.

Share Improve this question edited Oct 18, 2013 at 13:01 user asked Sep 20, 2013 at 3:05 useruser 311 silver badge8 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

As you seem to have PHP tag, so if using PHP, you can use file_get_contents(), like

$html = file_get_contents('url_of_site/page.html');

or with DOMDocument, like:

$doc = new DOMDocument();
$doc->loadHTMLFile('http://some_site./');    

$html = $doc->getElementsByTagName('p');
print_r($html);

Note:: Due to Same Origin Policy, you cant do it with just javascript. If you want to do it with Javascript you need to create a proxy kinda stuff, like have a test.php file in your own server, add code to fetch content from other site into test.php file, and call this test.php file using javascript ajax.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745572304a4633753.html

相关推荐

  • javascript - get a html element from another website (XSS) - Stack Overflow

    How can I get a html element from another website directly into my site (not using an iframe).For Examp

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信