scraping a website for the best rate

Status
Not open for further replies.

albatross710

Established Member
Joined
May 15, 2004
Posts
3,799
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
 
Read our AFF credit card guides and start earning more points now.

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.

Become an AFF member!

Join Australian Frequent Flyer (AFF) for free and unlock insider tips, exclusive deals, and global meetups with 65,000+ frequent flyers.

AFF members can also access our Frequent Flyer Training courses, and upgrade to Fast-track your way to expert traveller status and unlock even more exclusive discounts!

AFF forum abbreviations

Wondering about Y, J or any of the other abbreviations used on our forum?

Check out our guide to common AFF acronyms & abbreviations.
Back
Top