Skip to content

Instantly share code, notes, and snippets.

@Ozerich
Created April 8, 2011 20:03
Show Gist options
  • Save Ozerich/910597 to your computer and use it in GitHub Desktop.
Save Ozerich/910597 to your computer and use it in GitHub Desktop.
function parse($url)
{
$text = get_page($url);
preg_match_all('#<li class=rg_li.+?>(.+?)</li>#si', $text, $pics);
$items = array();
foreach($pics[1] as $data)
{
preg_match('#=&amp;h=(\d+)&amp;w=(\d+)&amp;sz=(\d+)&amp#sui', $data, $info);
preg_match('#imgurl=(.+?)&amp;#sui', $data, $pic_url);
preg_match('#imgrefurl=(.+?)&amp;#sui', $data, $site_url);
preg_match('#tbnid=(.+?)&amp;#sui', $data, $tbnid);
preg_match('#<img.+?src="(.+?)"#sui', $data, $preview_url);
$items[] = array(
"image_url" => $pic_url[1],
"preview_url" => $preview_url[1],
"info" => $info[2].' x '.$info[1].' - '.$info[3].' - '.substr($pic_url[1], strrpos($pic_url[1], '.') + 1),
"page" => $site_url[1],
"domain" => get_domain($site_url[1]),
"tbnid" => $tbnid[1],
);
}
return $items;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment