xenium
asked on
Creating a dynamic URL - link to results on Airbnb availability for tomorrow
hi,
I'm looking to create a link to a URL that can update automatically using today's date. Reason is I want to monitor the pricing on my Airbnb listings without having to type in all the search dates every time. So I'd like a URL which is essentially as below but with dates that update to say for example checkin= ** tomorrow ** &checkout= ** two days later **
https://www.airbnb.co.uk/s/Chippenham--UK?source=hdr&place_id=ChIJXdTdiABjcUgRSYcPSszcRq8&checkin=02-01-2017&checkout=05-01-2017&adults=2&children=0&infants=0&guests=2&room_types%5B%5D=Entire%20home%2Fapt&allow_override%5B%5D=&page=1&s_tag=JioWJWEX
Is there an easy way to do this, perhaps even an expression that the browser itself can parse.
Thanks
PS I've added the javascript topic as I'm interested to learn this and if this is a viable method then this could be a good test
I'm looking to create a link to a URL that can update automatically using today's date. Reason is I want to monitor the pricing on my Airbnb listings without having to type in all the search dates every time. So I'd like a URL which is essentially as below but with dates that update to say for example checkin= ** tomorrow ** &checkout= ** two days later **
https://www.airbnb.co.uk/s/Chippenham--UK?source=hdr&place_id=ChIJXdTdiABjcUgRSYcPSszcRq8&checkin=02-01-2017&checkout=05-01-2017&adults=2&children=0&infants=0&guests=2&room_types%5B%5D=Entire%20home%2Fapt&allow_override%5B%5D=&page=1&s_tag=JioWJWEX
Is there an easy way to do this, perhaps even an expression that the browser itself can parse.
Thanks
PS I've added the javascript topic as I'm interested to learn this and if this is a viable method then this could be a good test
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is updated code
javascript:function url() {
var startDate = new Date();
var y = startDate.getFullYear();
var m = startDate.getMonth() + 1;
if (m < 10) {
m = '0' + m;
}
var d = startDate.getDate();
if (d < 10) {
d = '0' + d;
}
var startString = d + "-" + m + "-" + y;
var endDate = new Date();
endDate.setDate(startDate.getDate() + 3);
y = endDate.getFullYear();
m = endDate.getMonth() + 1;
if (m < 10) {
m = '0' + m;
}
d = endDate.getDate();
if (d < 10) {
d = '0' + d;
}
var endString = d + "-" + m + "-" + y;
return 'https://www.airbnb.co.uk/s/Chippenham--UK?source=hdr&place_id=ChIJXdTdiABjcUgRSYcPSszcRq8&checkin=' + startString + '&checkout=' + endString + '&adults=2&children=0&infants=0&guests=2&room_types%5B%5D=Entire%20home%2Fapt&allow_override%5B%5D=&page=1&s_tag=JioWJWEX'
} window.open(url(),"_blank");
ASKER
Thanks, just a slight change.. start date needs to be tomorrow (today +1) and end date 2 days later (today +3)
I tried editting your code but fell on the first bit
thanks
I tried editting your code but fell on the first bit
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great thanks, that's perfect!
ASKER
PS I have a follow-up I'll post a link to a separate question in a moment
ASKER
This solution opens an additional blank tab by mistake, not a big issue but is there an easy way to avoid this?
Change
window.open(url(),"_blank");
towindow.open(url(),"_self");
ASKER
Great thanks a lot
ASKER
Open in new window