登录并获取网址Google Apps脚本 [英] login and fetch url Google Apps Script

查看:85
本文介绍了登录并获取网址Google Apps脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google Apps脚本从此网站将数据提取到我的Google电子表格中:

极有可能仅使用登录名&密码组合将无法执行此任务-如果它可以正常运行,则您链接到的网站将被编程不良且不安全.

总结一下,这是数据:

https://net.statev.de/auth/login

有效负载属性

  {密码":密码,用户名":用户名} 

I am trying to fetch data from this website into my google spreadsheet using Google Apps Scripts: https://net.statev.de/#/pages/buisness/storage/5aec8c9a3b82972b99e741c6

And need to login here first: https://net.statev.de/#/login

This is the function i came up with:

function fetch() {
var loginURL = 'https://net.statev.de/#/login';
  var dataURL = 'https://net.statev.de/#/pages/buisness/storage/5aec8c9a3b82972b99e741c6';
  var loginPayload = {
     'email':'testmail',
     'password':"test",
  };
  var loginOptions = {'method':'post','payload':loginPayload,'followredirects':false};
  var loginResponse = UrlFetchApp.fetch(loginURL,loginOptions);

  var loginHeaders = loginResponse.getAllHeaders();
  var cookie = [loginResponse.getAllHeaders()["Set-Cookie"]];
  cookie[0] = cookie[0].split(";")[0];
  cookie = cookie.join(";");

  var dataHeaders = {'Cookie':cookie};
  var dataOptions = {'method':'get','headers':dataHeaders};
  var dataResponse = UrlFetchApp.fetch(dataURL,dataOptions);

  Logger.log(dataResponse);
}

My problem here is, I only get 404 Error from the UrlFetchApp.fetch and i don't really get what I am doing wrong. Is it possible that the website blocks my fetch request?

解决方案

The registration form doesn't work, so I couldn't test this. That said, it seems that you are not calling the correct authorization endpoint. You can use Chrome Dev Tools as a network sniffer

It's extremely likely that using just the login & password combo will not do the job - if it does work, the website you link to is lousily programmed and not secure.

To sum up, here's the data:

https://net.statev.de/auth/login

Payload properties

 {"password": password, "username": username}

这篇关于登录并获取网址Google Apps脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆