Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

362
Views
¿Cómo cargar dinámicamente páginas web AJAX externas en Google Apps Script?

Quiero cargar una página web generada por JS (por ejemplo, AngularJS o similar) y luego rasparla usando (solo) Google Apps Script. ¿Cómo puedo lograr eso?

Estoy buscando algo como:

 const response = UrlFetchApp.fetch( urlToExternalJsPage ); const content = response.getContentText(); // scrape content

Solo, tal vez, reemplazar UrlFetchApp con una llamada a una biblioteca o algo así. ¿Quizás una biblioteca Titiritero para GAS, la biblioteca Cheerio para GAS o algo más?

¿Cómo puedo cargar una página JS cargada externamente y leer el HTML de esa página después de generarla para rasparla?

Idea 1

Encontré este artículo: La mejor manera de cargar Javascript que proporciona el siguiente código.

 function loadScript(url, callback){ var script = document.createElement("script") script.type = "text/javascript"; if (script.readyState){ //IE script.onreadystatechange = function(){ if (script.readyState == "loaded" || script.readyState == "complete"){ script.onreadystatechange = null; callback(); } }; } else { //Others script.onload = function(){ callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); }

El código real en su página termina luciendo así:

 <script type="text/javascript" src="http://your.cdn.com/first.js"></script> <script type="text/javascript"> loadScript("http://your.cdn.com/second.js", function(){ //initialization code }); </script>

El problema con este enfoque es que estoy tratando de mantenerme estrictamente del lado del servidor. No estoy tratando de publicar páginas HTML y/o servirlas.

Idea 2

Encontré este artículo que parece describir una biblioteca de titiriteros para GAS. Lo traduje del japonés usando Google Translate. El problema es que requiere usar Google Cloud Platform y quiero evitar eso. También quiero evitar configurar cualquier facturación y permanecer estrictamente dentro de Google Apps Script.

Idea 3

Tal vez haya una forma de usar el navegador que viene con el servicio de interfaz de usuario. Específicamente, la barra lateral?

En esta página , encontré el siguiente ejemplo de importación de páginas web en una página de servicio HTML utilizando un IFRAME .

Código.gs
 function doGet() { var template = HtmlService.createTemplateFromFile('top'); return template.evaluate(); }
top.html
 <!DOCTYPE html> <html> <body> <div> <a href="http://google.com" target="_top">Click Me!</a> </div> </body> </html>
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!