Parsing image URLs in remote HTML as JSON Parsing image URLs in remote HTML as JSON json json

Parsing image URLs in remote HTML as JSON


You can't do this directly becasue of same origin policy, you will be able to use iframe to fetch web page but you can't read it's content. you need simple server script that will be a proxy. If you use php and it allow to open urls as files you will be able to use this:

<?php if (isset($_GET['url'])) {   echo json_encode(get_file_contents($_GET['url']));}

and then using ajax you can fetch pages using urls and you can use jquery as a parser.

$.getJSON('fetch.php', {url: "http://google.pl"}, function(html) {   $(html).find('img');});