How to get info from another website from my HTML page?
What is needed is as follows:
I have an HTML webpage and I need to access another website and get something from its source code.
I want to run something like
link = "http://www.google.com";
doc.querySelectorAll('#courses_menu > ul > li > a'); // Apply on the link.
t开发者_JAVA百科o get what I need from the link and use it!
However, I am using Jetpack slide bar.
Does it have to do anything with HTTP requests?
I think you could pull the entire page using an Ajax request, put the content in a hidden iframe, and then manipulate the DOM in the iframe. Something like (here using the jQuery framework)
<iframe id="holder" style="display: none">
<script type="text/javascript">
$("#holder").load("http://www.google.com",function () {
$link = $("#holder").contents().find("#courses_menu > ul > li > a");
});
</script>
I recommend using a Ajax (e.g. jquery) with a PHP proxy on the same Webserver. The Proxy loads the the remote webpage and is then available under the same domain.
Don't forget to protect the proxy against abuse.
Have a page which will have a result of your query "doc.querySelectorAll('#courses_menu > ul > li > a');"
Add an IFrame in your page, set the src as the page which has the above result.
<iframe src='pagenamewhichhasresult'/>
You can include other website content in your html document using an iframe. However, due to the same original policy, you cannot have script from your domain affect content from another domain. In other words, you can't write some javascript to manipulate the content of some other web page you put in an iframe. The script would have to come from that domain as well.
If you want to insert another website page or data the
Just use :-
<iframe src="https://libcon.in/" frameborder="0" scrolling="yes"></iframe>
want more then use this Link
精彩评论