Skip to content
Advertisement

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.

to 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?

Answer

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>
Advertisement