Receive information after completing a reservation (cURL, iFrame ...?) On an external website

I am working on a difficult problem: to find a solution for receiving data after the booking process. Basically, I have a page with the form (SLIM FORM), which I should automatically fill out with information coming from the provider form (for example, easyjet.com or hotels.com, anywhere in the reservation). For example: https://secure.booking.com/hotel/es/royal.html?sid=1c2bab12a0c64a541728840f52cd6401;errorc_checkin_invalid=checkin;errorc_intro_error_message_invalid_intro_error_vror_vror_vror_vror_stror_vror_ver1_error_vror_v_rever_v_1_1_0_1_0_0_0 1; errorv_hostname = www.booking.com; errorv_nr_rooms_9022801_80638194_0 = 1; errorv_interval = 1 the information in my order is what I need to get.

enter image description here

I did some tests, and here is what I found out so far:

It is not possible to have both pages on the same page because there is no communication with the external server with cURL, and with iframes it leaves the ASAP page when the src iframe changes.

So, I decided that the booking process should occur on a separate page, in the domain of the booking provider (easyjet.com ...)

1) I have the right to consider making a reservation on a real site or is there a way to include an external website on my page and complete the entire booking process in it (basically filling out forms upon check-out, check-in date, etc.) ...) ?

If this is not possible, I did some tests with cURL and came to this conclusion:

_ I will need to determine the appropriate regular expression for each provider, and I get the impression that some have mechanisms for identifying cURL and blocking. (e.g. lufthansa.com) But it works great with others (booking.com)

I have 2 additional questions:

2) Are there better solutions than cURL for parsing HTML code on a page (especially since it does not work if the URL does not include sessionID)? I was thinking maybe using something like Selenium ...

3) How can I start a cURL session in another tab or window? (I was thinking of a bookmark-like system that might run some JavaScript code)

Thanks for your answers and sorry for the length :-)

Update . Based on the answers received, here are some fresh thoughts: for large providers (easyjet, hotels.com, etc.) I will use the API, if available. For small providers (for example, http://www.hotel-gare-clermont.com/en,1,6217.html ), I think the proxy solution is different and I won’t receive any legal complaints from "Hotel de la Gare", adding visibility to these small providers. What do you think?

+7
source share
3 answers

1) It is possible, but it has a side effect of illegality of borders. You cannot just view provider forms and reserve your pages in an iframe. If the suppliers caught you, you will most likely be sued.

You need a partnership agreement with various providers. with this agreement, they are likely to open the Application Programming Interface (API) for you. This will allow you to request their site more directly and place orders in a clean and approved way.


2) cURL is a great library that works very well with web pages. There are many examples on the Internet for extracting a page into a string. In terms of parsing this line, in an ideal world, you can use an XML parser. Unfortunately, HTML pages are very poorly designed, which makes them difficult to parse. Most coders, when they have to parse HTML fragments, usually use regular expressions.

To get the session ID, your first cURL request should be in the login form on example.com. Confirm the submission of the login form, trying to get http://example.com?username=bob&pass=secret . You can verify a valid login by looking at the text "successful login" or a similar server response. You can get the session ID (if it is a cookie) from the response headers. Subsequent cURL requests should send your cookie.


3) cURL works on the server side, therefore it is absolutely not known about your open tabs. You can use Javascript for tabbed queries, but I'm sure most browsers will not let you do this for security reasons.

+7
source

Sending the user directly to the supplier is a much more reliable solution, since you give the user control over the process. But, of course, you lose control of the process :)

In addition, you need to create a proxy server on your server, which requests the site on behalf of your user:

end-user yourdomain easyjet | | | |-----search----->| | |<--booking form--| | |---user data-->| | | |---forward-->| | |<--result----| |<--pass to user--| | | | | vvv 

For the end user, booking is done with you; to easyjet / lufthansa / whoever you are, you seem to be a customer. The problem is that each website is different and you will have a lot of work adapting your system to what each (or most) website requires, and, as you have already noticed, airlines do not want you to follow your customs. That is why many broker's websites (kelkoo, gocompare ...) started to do what you plan, but turned out to be famous advertisements.

+6
source

The best way to use APIs from vendors. The next is cURL or IFrame.

You can use JSON / AJAX, which supports cross-site requests, and you can control the exit.

0
source

All Articles