How to fetch search results from another site

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pankajshr_jpr
Forum Newbie
Posts: 3
Joined: Fri Jun 19, 2009 2:04 am

How to fetch search results from another site

Post by pankajshr_jpr »

HI I am a new bie dont know where to post this topic.
Actually I want to write a php code which could fetch the flight informations from various airlines sites. These sites have a form in which user can enter information and search the flight. I want to display those results in my site when a user comes to my site and search about flight. For eg. user want to search flights from city-1 to city-2 then he enter the information on my site and my script should search flights according to that information on various airlines sites and display the results with the tag of which ailines is providing this flight.
Could any one plz suggest how to do it?
azylka
Forum Commoner
Posts: 40
Joined: Sat Dec 06, 2008 9:11 pm

Re: How to fetch search results from another site

Post by azylka »

Just throwing this out there:
Google uses the GET function in their URL to give the search term to the page that takes it and processes it.
Google's URL: http://www.google.com/#q=YOUR_SEARCH_TERM_HERE
Find the URL you could use for each of the airline's sites.
Then use the iFrame attribute in HTML to display the sites. (I'm thinking about <FORM TARGET="IFRAME_NAME" method="GET" action="AIRLINE_SEARCH_URL">, but I'm not sure. You'll have to figure that out.)

Delta's search URL is: http://www.delta.com/flifo/servlet/Delt ... ht_number=FLIGHT_NUMBER_HERE&flight_date=Today&request=main

Using a form, have your user submit the flight number like this: (This form HAS been tested by me.)

Code: Select all

 
<form method="GET" action="http://www.delta.com/flifo/servlet/DeltaFlifo?airline_code=DL&flight_number=815&flight_date=Today&request=main">
<input name="airline_code" value="DL" type="hidden">
Flight Number: <input name="flight_number">
<input name="flight_date" value="Today" type="hidden">
<input name="request" value="main" type="hidden">
<br>
<input type="submit" value="Search!">
</form>
 
Once again, just throwing this out there. Don't yell at me if you already have this code. :wink:
All you have to find out now is how to put those results into an iFrame on your results page with the other Airlines' search results.
pankajshr_jpr
Forum Newbie
Posts: 3
Joined: Fri Jun 19, 2009 2:04 am

Re: How to fetch search results from another site

Post by pankajshr_jpr »

Thanks for support, but it is going to have lot of problems:
Many sites doesnt uses the GET method for processing the search query. For eg. even delta site doesn't uses GET method for searching a flight between delhi to mumbai. It uses GET only for displaying a particular flight that has unique flight number. But I need to search a flight also.
Many of the sites uses POST method or even javascript to process the search results i.e. the URL doesn't changes while searching.

Can I query the file which is being called by form used by flight sites during searching by using POST/GET or call the functions used by flight sites for searching by any means??
Then it would be very easy as i would call the function directly and get the results.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: How to fetch search results from another site

Post by Eric! »

Go to your target sites page, view the html for their form, copy down their variables. Then figure out what they are putting in those variables. You can run a tool like web scarab to capture the _post or _get data. Once you have that, then your php script can post that data via a faked html get header to their php script that their form calls for generating the results. You might need to spoof the 'HTTP_REFERER' variable too.

I haven't done this personally, but I have seen an easy way to post and get data using the snoopy.class
http://phpstarter.net/2008/12/how-to-po ... p-scripts/
pankajshr_jpr
Forum Newbie
Posts: 3
Joined: Fri Jun 19, 2009 2:04 am

Re: How to fetch search results from another site

Post by pankajshr_jpr »

Thanks a lot ... It really required it..
many many thanks
Post Reply