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
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 the decimalPoint I was just going to search up the the first decimal point following the index res_rate_lowest_standard
Thoughts appreciated.
Alby
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