John Davidson

php - Show top google images on page using a request system

0 comments
Message:


public function Index($realm = false, $id = false) {

clientLang("loading", "item");

// Make sure item and realm are set
if (!$id || !$realm) {
die(lang("no_item", "item"));
}


$this -> realm = $realm;

$cache = $this -> cache -> get("items/tooltip_".$realm."_".$id."_".getLang());
$cache2 = $this -> cache -> get("items/item_".$realm."_".$id);

if ($cache2 !== false) {
$itemName = $cache2['name'];
}
else {
$itemName = lang("view_item", "item");
}

$this -> template -> setTitle($itemName);

$icon = $this -> getIcon($id);

if ($cache !== false) {
$item = $cache;
}
else {
$item = $this -> template -> loadPage("ajax.tpl", array('module' => 'item', 'id' => $id, 'realm' => $realm, 'icon' => $icon));
}

$content = $this -> template -> loadPage("item.tpl", array('module' => 'item', 'item' => $item, 'icon' => $icon));

$data3 = array(
"module" => "default",
"headline" => "<span style='cursor:pointer;' onClick='window.location=\"".$this -> template -> page_url."armory\"'>".lang("armory", "item")."</span> &rarr; ".$itemName,
"content" => $content
);

$page = $this -> template -> loadPage("page.tpl", $data3);

$this -> template -> view($page, "modules/item/css/item.css");
}


While I do have a function to send informations, how could I make use of this system in a way that would make possible for me to use a pre-search on Google image and show this on the user end when he is selecting a specific item per example.


Clicking on item 87652 returns you with the item page + a Google image search with the top 2-3 results of the ID searched (just an example)



My Answer:
"en"); // Set client language to English

$query = "top google images"; // Query to search for top google images
$url = "https://www.google.com/search?q=" . urlencode($query) . "&tbm=isch"; // Construct the Google Images search URL

$html = file_get_contents($url); // Get the HTML content of the Google Images search page

// Use regular expressions to extract the image URLs from the HTML content
preg_match_all('/]+src="([^">]+)"/', $html, $matches);

// Display the top Google Images on the page
foreach ($matches[1] as $image) {
echo 'Google Image';
}
}

Rate this post

3 of 5 based on 9089 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us