http - Connecting to a Website with Google Apps Script -


i've been trying use gas's urlfetchapp connect external website. however, website redirects me "select country" page http 302 error no matter web address use.

var options = {     'mutehttpexceptions':true   };    var response = urlfetchapp.fetch("http://www.idtdna.com/site/account", options);   logger.log(response.getallheaders());   logger.log(response.getcontenttext());   var cookie = response.getallheaders()['set-cookie']+', cn=us&dateset=7/28/2015 5:48:55 pm; path=/; domain=www.idtdna.com';   logger.log(cookie);   var header = {'cookie':cookie};   var o2 = {     'headers':header,     'mutehttpexceptions':true   };   var r2 = urlfetchapp.fetch("https://www.idtdna.com/country.aspx", o2);   logger.log(r2.getallheaders());   logger.log(r2.getcontenttext()); 

here code. i've been trying send cookie either i've formatted wrong or sending incorrectly because keep getting redirected regardless.

after setting mutehttpexceptions option 'true' , further investigating website mentioned, think happens because of cookies website.

so when first access website, there no valid cookie. creates session , sets cookie. might store session details country well.

you can try setting cookie while fetching url passing cookie values in request header. check page details on how send cookie through header.

hope helps!


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -