Help With Web Scraping using GAS

238 views
Skip to first unread message

Gabriel Aguiar - ILHASERVICE

unread,
Feb 17, 2022, 11:21:52 AM2/17/22
to Google Apps Script Community
Hello Guys, I'm really new at google app scripts and I really need help with this program that I'm trying to develop.

First I need to use script to enter this url: 
http://www3.mte.gov.br/sistemas/mediador/ConsultarInstColetivo

I need to fill this checkbox and fields, anyone knows how can I do that?

I was using cheerios to scrap the page, but that's not helping to fill the fields and check the checkboxes...


Thanks you so much.



Clark Lind

unread,
Feb 18, 2022, 8:33:19 AM2/18/22
to Google Apps Script Community
That kind of thing is outside the scope of Google apps. There are a few other javascript libraries that can do this. Check out this channel for some ideas, even possibly integrating with Apps script if you had to:
https://www.youtube.com/watch?v=xUqK8VFhu64

Hugo Tadashi Kussaba

unread,
Feb 19, 2022, 4:28:13 AM2/19/22
to Google Apps Script Community
Hi Gabriel, I did a script for getting data from Brazil Central Bank (https://github.com/htadashi/CalculadoraCidadao.gs) and I think some techniques that I used will also help you :)

1. Check the network activity using your browser DevTools (if you use Chrome, you can check this tutorial: https://developer.chrome.com/docs/devtools/network/). This will help to "reverse engineer" what requests the browser is doing when sending the form.
2. You can send data for forms using UrlFetchApp's payload option: https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetch(String,Object)

Good luck and praying for you success! 🙏

Gabriel Aguiar - ILHASERVICE

unread,
Feb 23, 2022, 3:12:50 PM2/23/22
to Google Apps Script Community

It really helped, now I got the knowloged of how to make I post request. But I have one problem, the website that I'm trying to sent a request is chache-Control: private. So I alway get the 500 error, everytime, eventhough my request is exactly the same as appers in the network tool. Do you know what can I do to solve that?

Best Regards.
Reply all
Reply to author
Forward
0 new messages