scraping a website for the best rate

Status
Not open for further replies.

albatross710

Established Member
Joined
May 15, 2004
Posts
3,704
I've often read the flyertalk forum which list three digit codes for discounts at various hotels. ie Marriott.

Being a newbie to the world of javascripting it doesn't take long to realise I can quickly generate all of the available Corporate codes from AAA, AAB.... AA9 ..... 999. I'll name that generated code as corporateCode Then programmatically fetch all of the results for my intended travel dates with a URL that looks like

page = new URLResource("http://www.marriott.com.au/reservation/availabilitySearch.mi?propertyCode="+propertyCode+"&hwsCurrency="+hwsCurrency+"&fromDate="+fromDate+"&toDate="+toDate+"&isHwsGroupSearch=true&isSearch=false&numberOfNights=1&clusterCode=other&corporateCode="+corporateCode);

such that the URL will appear as

http://www.marriott.com.au/reservat...fNights=1&clusterCode=other&corporateCode=ABY


I am able to successfully go through each line of each page and use indexOf("standard") to find some strings, but whenever I change it to get closer to the figure I want indexOf("res_rate_lowest_standard") I don't get a value returned.

What I was hoping to do was find where that string is on each page and then return the value that next appears after that.

I was then intending to update my variables bestCode & bestRate each time I found a lower value. At the end, output these variable.

Can anyone suggest a way of scrapping the page to obtain the rate.

Here is the code I'm currently using which is not find the string:

for (String line : page.lines()) {
priceLocation = line.indexOf("res_rate_lowest_standard");
if (priceLocation >0){
rateString = line.substring(priceLocation,decimalPoint);
System.out.println("For Corporate Code "+corporateCode+" the best rate is "+rateString);
}

for the decimalPoint I was just going to search up the the first decimal point following the index res_rate_lowest_standard

Thoughts appreciated.

Alby
 
The Frequent Flyer Concierge team takes the hard work out of finding reward seat availability. Using their expert knowledge and specialised tools, they'll help you book a great trip that maximises the value for your points.

AFF Supporters can remove this and all advertisements

seems the page that I get returned when I retrieve it is different to the page I get when i view it in my browser.

tricky
 
Status
Not open for further replies.

Enhance your AFF viewing experience!!

From just $6 we'll remove all advertisements so that you can enjoy a cleaner and uninterupted viewing experience.

And you'll be supporting us so that we can continue to provide this valuable resource :)


Sample AFF with no advertisements? More..

Currently Active Users

Back
Top