/**
* Открывает URL и возвращает код страницы
* Telegram - @ProgrammerForever
*
* @param {string} URL URL который нужно открыть
* @param {boolean} isCut Указывает, нужно ли обрезать страницу до 50000 символов по длине, по умолчанию false
* @param {boolean} noScript Указывает, нужно ли удалять скрипты из кода
* @return Исходный код страницы
* @customfunction
*/
function getHTML(URL,isCut,noScript) {
if ((URL === undefined)||(URL == "")) { return "#ОШИБКА Пустой URL";};
if (isCut === undefined) {var isCut=true;};
if (noScript === undefined) {var noScript=true;};
if (URL.map){ //Если задан диапазон
return URL.map(getHTML);
}else{
try {
var payload = {
};
var headers={
};
var options = {
'method' : 'get',
'headers' : headers,
'payload': payload
};
var response = UrlFetchApp.fetch(URL,options);
var charset=response.getAllHeaders["charset"];
var responseText=response.getContentText(charset?charset:"UTF-8");
if (noScript){
responseText=responseText.replace(/<script[^>]*>(?:(?!<\/script>)[^])*<\/script>/gmi,"");
responseText=responseText.replace(/<!--.*?-->/gmi,"");
responseText=responseText.replace(/<link.*?\/>/gmi,"");
responseText=responseText.replace(/<meta.*?\/>/gmi,"");
responseText=responseText.replace(/[\n\r\t]/gmi,"");
};
if (isCut&&(responseText.length>50000)){return responseText.substring(0,50000);}else{return responseText;};
} catch (err) {
return "#ОШИБКА "+err.message;
};
};
};
ping emmet.io
PING emmet.io (128.199.54.7): 56 data bytes
64 bytes from 128.199.54.7: icmp_seq=0 ttl=58 time=65.192 ms
^C
--- emmet.io ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 65.192/65.192/65.192/0.000 ms
wget -r -k -l 7 -p -E -nc http://site.com/
function sleep(ms) {
ms += new Date().getTime();
while (new Date() < ms){}
}
npm install babel-core babel-preset-es2015 --save
{
"presets": ["es2015"],
}
require('babel-core/register');
require('./server');
var voices = window.speechSynthesis.getVoices();
setTimeout(function() { voices = window.speechSynthesis.getVoices(); }, 1000);
function findVoice(lang) {
for (var i = 0; i < voices.length; i++) {
if (voices[i].lang === lang) { return voices[i]; }
}
return null;
}
this.speak = function(s) {
if (!window.speechSynthesis) { return; }
var utterance = new SpeechSynthesisUtterance(s);
utterance.lang = "ru-RU";
utterance.voice = findVoice(utterance.lang);
window.speechSynthesis.speak(utterance);
};