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
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;

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.