I’m doing web scraping with javascript.
I’m wondering how I can store all the html code in a variable called websiteContent ?
Because according to my understanding javascript has only 3 types of variables var let and const , all of which are not enough to store at all.
What should I do?
This is my code:
function test() {
var url = "https://pantip.com/topic/34943783"
//fetch site content
var websiteContent = UrlFetchApp.fetch(url);
var fetchTime = Utilities.formatDate(new Date(), 'Etc/GMT', "yyyy-MM-dd HH:mm:ssZ"); // "yyyy-MM-dd'T'HH:mm:ss'Z'"
//extract data
var laDeathsRegExp = new RegExp(/(?<=title>)(.*)(?= - Pantip)/m);
var laDeathsMatchText = laDeathsRegExp.exec(websiteContent);
Logger.log(websiteContent.getContentText());
Logger.log('' + laDeathsMatchText);
}