javascript / php - Get src of image from the URL of the site -
i noticed @ http://avengersalliance.wikia.com/wiki/file:effect_icon_186.png, there image (a small one) there. click on it, brought page: http://img2.wikia.nocookie.net/__cb20140312005948/avengersalliance/images/f/f1/effect_icon_186.png.
for http://avengersalliance.wikia.com/wiki/file:effect_icon_187.png, after clicking on image there, brought page: http://img4.wikia.nocookie.net/__cb20140313020718/avengersalliance/images/0/0c/effect_icon_187.png
there many similar sites, http://avengersalliance.wikia.com/wiki/file:effect_icon_001.png, http://avengersalliance.wikia.com/wiki/file:effect_icon_190.png (the last one).
i'm not sure if image link related link of parent site, may know, possible http://img2.wikia.nocookie.net/__cb20140312005948/avengersalliance/images/f/f1/effect_icon_186.png
string, string http://avengersalliance.wikia.com/wiki/file:effect_icon_186.png
, using php or javascript? appreciate help.
here small php script can this. uses curl content , domdocument parse html.
<?php /* * educational purposes */ function get_wiki_image($url = '') { if(empty($url)) return; $curl = curl_init($url); curl_setopt($curl, curlopt_returntransfer, true); $output = curl_exec($curl); curl_close($curl); $dom = new domdocument; libxml_use_internal_errors(true); $dom->loadhtml($output); libxml_use_internal_errors(false); return $dom->getelementbyid('file')->firstchild->firstchild->getattribute('src'); } echo get_wiki_image('http://avengersalliance.wikia.com/wiki/file%3aeffect_icon_186.png');
Comments
Post a Comment