Jump to content

Search external website


liamloveslearning

Recommended Posts

Hi all,

Im just wondering how you go about building a search function to another website, So on my webpage i could have a search that searchs the itunes store or something?

 

Has anybody previous experience with this or can point me in the right direction, I have googled this but all im being shown is an overwhelming amount of results for google instant! thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/213286-search-external-website/
Share on other sites

You can do that with using cURL or file_get_contents()

 

first you need to do query on site and then fetch results and with some regex display that to your end user. for example if itunes search query is here

 

itunes.com/search.php?query=search+something

 

then you need to  point in your curl session to that url so a simple query should look like this

$string = " search something";
$url = "itunes.com/search.php?query=" . $string; 
$ch = curl_init(); 
curl_setopt($ch,CURLOPT_URL,$url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
$result = curl_exec($ch); 
curl_close($ch); 

// rather then echo you need to parse returned page and display results
echo $result;

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.