UrlFetchApp is not return full source code - google-apps-script
If I try to simply get the source html of a page I cannot get the full source. It breaks in some point. Returns less than half of the exact source html.
var pagedata = UrlFetchApp.fetch("https://stackoverflow.com");
var html = pagedata.getContentText();
Logger.log(html);
returns:
[20-01-06 11:37:12:483 AST] <!DOCTYPE html>
<html class="html__responsive html__unpinned-leftnav">
<head>
<title>Stack Overflow - Where Developers Learn, Share, & Build Careers</title>
<link rel="shortcut icon" href="https://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico?v=4f32ecc8f43d">
<link rel="apple-touch-icon" href="https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png?v=c78bd457575a">
<link rel="image_src" href="https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png?v=c78bd457575a">
<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml">
<meta name="description" content="Stack Overflow is the largest, most trusted online community for developers to learn, share their programming knowledge, and build their careers."/>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0">
<meta property="og:type" content= "website" />
<meta property="og:url" content="https://stackoverflow.com/"/>
<meta property="og:site_name" content="Stack Overflow" />
<meta property="og:image" itemprop="image primaryImageOfPage" content="https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon#2.png?v=73d79a89bded" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:domain" content="stackoverflow.com"/>
<meta name="twitter:title" property="og:title" itemprop="name" content="Stack Overflow - Where Developers Learn, Share, & Build Careers" />
<meta name="twitter:description" property="og:description" itemprop="description" content="Stack Overflow | The World’s Largest Online Community for Developers" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdn.sstatic.net/Js/stub.en.js?v=805608b6266c"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Shared/stacks.css?v=d0797a2dd6f2" >
<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/stackoverflow/primary.css?v=b556f32ececa" >
<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Shared/Product/product.css?v=b21a396b1289" >
<link rel="alternate" type="application/atom+xml" title="Feed of recent questions" href="/feeds">
<link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Shared/Channels/channels.css?v=05e29db3ebd2" >
<script>
StackExchange.init({"locale":"en","serverTime":1578299832,"routeName":"Home/Index","stackAuthUrl":"https://stackauth.com","networkMetaHostname":"meta.stackexchange.com","site":{"name":"Stack Overflow","description":"Q&A for professional and enthusiast programmers","isNoticesTabEnabled":true,"enableNewTagCreationWarning":true,"insertSpaceAfterNameTabCompletion":false,"id":1,"childUrl":"https://meta.stackoverflow.com","negativeVoteScoreFloor":null,"enableSocialMediaInSharePopup":true,"protocol":"https"},"user":{"fkey":"57ec692c216f7cb3d5bad86dceda031ede043f08f80e49d7b3a503d818751da0","tid":"0e7426d0-71e0-4546-1387-57279d43b924","rep":0,"isAnonymous":true,"isAnonymousNetworkWide":true},"events":{"postType":{"question":1},"postEditionSection":{"title":1,"body":2,"tags":3}},"story":{"minCompleteBodyLength":75,"likedTagsMaxLength":300,"dislikedTagsMaxLength":300},"jobPreferences":{"maxNumDeveloperRoles":2,"maxNumIndustries":4},"svgIconPath":"https://cdn.sstatic.net/Img/svg-icons","svgIconHash":"53ac0f6119d0"}, {"userProfile":{"openGraphAPIKey":"4a307e43-b625-49bb-af15-ffadf2bda017"},"userMessaging":{},"tags":{},"snippets":{"renderDomain":"stacksnippets.net","snippetsEnabled":true},"slack":{"sidebarAdDismissCookie":"slack-sidebar-ad"},"site":{"allowImageUploads":true,"enableImgurHttps":true,"enableUserHovercards":true,"forceHttpsImages":true,"styleCode":true},"questions":{"showPostNoticesV2":true},"paths":{},"monitoring":{"clientTimingsAbsoluteTimeout":30000,"clientTimingsDebounceTimeout":1000},"mentions":{"maxNumUsersInDropdown":50},"markdown":{"asteriskIntraWordEmphasis":true},"flags":{"allowRetractingCommentFlags":true,"allowRetractingFlags":true},"comments":{},"accounts":{"currentPasswordRequiredForChangingStackIdPassword":true}});
StackExchange.using.setCacheBreakers({"js/prettify-full.en.js":"e75c65979e48","js/moderator.en.js":"b6ce25c91468","js/full-anon.en.js":"bcefec08f832","js/full.en.js":"bf88016bdeb3","js/wmd.en.js":"28e8cee04c52","js/mobile.en.js":"a168d277c579","js/help.en.js":"373025d0518f","js/tageditor.en.js":"693662f7ff37","js/tageditornew.en.js":"803d1cb2516d","js/inline-tag-editing.en.js":"b5436857e5dd","js/revisions.en.js":"055fbe1202e9","js/review.en.js":"7b6845367497","js/tagsuggestions.en.js":"dba299567acf","js/post-validation.en.js":"bc3e5be5330d","js/explore-qlist.en.js":"8498d0bb288b","js/events.en.js":"57fa0feb2feb","js/keyboard-shortcuts.en.js":"ab1fdc223933","js/adops.en.js":"6b9883f0531e","js/begin-edit-event.en.js":"cb9965ad8784","js/ask.en.js":"e4dd8c66240e","js/question-editor.en.js":"","js/snippet-javascript-codemirror.en.js":"07eb23cd1f61"});
StackExchange.using("gps", function() {
StackExchange.gps.init(true);
});
</script>
<noscript id="noscript-css"><style>body,.top-bar{margin-top:1.9em}</style></noscript>
</head>
<body class="home-page unified-theme">
<div id="notify-container"></div>
<div id="custom-header"></div>
<header class="top-bar js-top-bar top-bar__network _fixed">
<div class="wmx12 mx-auto grid ai-center h100" role="menubar">
<div class="-main grid--cell">
<span class="ps-relative"></span>
<div class="topbar-dialog leftnav-dialog js-leftnav-dialog dno">
<div class="left-sidebar js-unpinned-left-sidebar" data-can-be="left-sidebar" data-is-here-when="sm md lg"></div>
</div>
<a href="https://stackoverflow.com" class="-logo js-gps-track"
data-gps-track="top_nav.click({is_current:true, location:1, destination:8})">
<span class="-img _glyph">Stack Overflow</span>
</a>
</div>
<ol class="list-reset grid gs4" role="presentation">
<li class="grid--cell">
<a href="#"
class="-marketing-link is-selected js-gps-track js-products-menu"
aria-controls="products-popover"
data-controller="s-popover"
data-action="s-popover#toggle"
data-s-popover-placement="bottom"
data-gps-track="top_nav.products.click({location:1, destination:1})"
data-ga="["top navigation","products menu click",null,null,null]">
Products
</a>
</li>
<li class="grid--cell md:d-none">
<a href="/teams/customers" class="-marketing-link js-gps-track"
data-gps-track="top_nav.products.click({location:1, destination:7})"
data-ga="["top navigation","customers menu click",null,null,null]">Customers</a>
</li>
<li class="grid--cell md:d-none">
<a href="/teams/use-cases" class="-marketing-link js-gps-track"
data-gps-track="top_nav.products.click({location:1, destination:8})"
data-ga="["top navigation","use cases menu click",null,null,null]">Use cases</a>
</li>
Original source has 4168 lines. First of all there is no closing body, html tags. How can I get the full source code of a page with UrlFetchApp?
The Logger.log() method expects a string or other JavaScript object. The logs can only hold a limited amount of data, so avoid logging large amounts of text.
Source
The character limit for the logger.log function is not specified, but your variable html does contain all of your data.
Related
Font Awesome not all icons showing
I'm using font awesome CDN to use the icons but not all icon do show, i put 2 examples of 2 icons, the first one shows and the second does not, it rather shows as an X inside a square, what is going on ? <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Alarabiyah | Breaking News From Around The World</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css" integrity="sha512- xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <link rel="stylesheet" href="styles.css" /> </head> <body> <header class="header"> <div class="header__top"> <div class="header__top-logo-container"> <img src="logo.png" alt="logo" class="header__top-logo-image" /> </div> <div class="header__top-controls"> <i class="fa-solid fa-magnifying-glass"></i> // SHOW <i class="fa-regular fa-magnifying-glass"></i> // SHOWS AS AN X INSIDE A SQUARE <div class="header__top-theme"></div> </div> </div> </header> </body> </html> i have tried using different CDNs, i've also used the Font Awesome Kit, but it doesn't change anything
It is because "fa-regular fa-magnifying-glass" is not free. You can check this out using below link: Font awesome free icons
Linkedin not showing thumbnail from Github-pages hosted website
On my linkedIn profile my personal website hosted on Github-pages is not showing a thumbnail. I followed the guidelines available on LinkedIn but It still does not work. I removed some of personal details from this code. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta property="og:title" content="ME"/> <meta property="og:image" content="img/snapshot.PNG"/> <meta property="og:description" content="A description"/> <meta property="og:url" content="URL to the site" /> <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" /> <link href="https://fonts.googleapis.com/css?family=Reem+Kufi|Roboto:300" rel="stylesheet"> <link href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" rel="stylesheet"> <link rel="stylesheet" href="css/reset.css"> <link rel="stylesheet" href="css/styles.css"> <link rel="stylesheet" href="css/themes/grey-white.css"> </head> <body> <main> <div class="intro">STUFF</div> </main> </body> </html> Folder structure: index.html css/ reset.css styles.css themes/ grey-white.css img/ snapshot.PNG favicon.ico circuit-board.svg What am I missing here? Is this a limitation in Linkedin, Github-pages or have I done something wrong?
You need to add host address before img/snapshot.PNG in og:image tag. This will solve the problem.
HTML Text not centering
I have been having a problem with my code, I wanted the text to be in the centre, but no matter what I do, it just won't go there. I have added a comment indicating the location of the text I wanted to be centred. Any help is appreciated. <!DOCTYPE html> <html lang="en" class="no-js"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Mix Pics</title> <meta name="description" content="A photography-inspired website layout with an expanding stack slider and a background image tilt effect" /> <meta name="keywords" content="photography, template, layout, effect, expand, image stack, animation, flickity, tilt" /> <meta name="author" content="Codrops" /> <link rel="shortcut icon" href="favicon.ico"> <link rel="stylesheet" type="text/css" href="css/normalize.css" /> <link rel="stylesheet" type="text/css" href="css/flickity.css" /> <link rel="stylesheet" type="text/css" href="css/main.css" /> <script src="js/modernizr.custom.js"></script> </head> <body> <div class="container"> <div class="hero"> <div class="hero__back hero__back--static"></div> <div class="hero__back hero__back--mover"></div> <div class="hero__front"></div> </div> <header class="codrops-header"> <div class="codrops-links"> <a class="codrops-icon codrops-icon--prev" href="index.html" title="Home Page"><span>Home Page</span></a> <a class="codrops-icon codrops-icon--drop" href="index.html" title="Home Page"><span>Home Page</span></a> </div> <h1 class="codrops-title">Mix <span>Pics</span></h1> <div align="center"> <h3>About</h3> <!-- This text for some reason is in the top right hand corner, not the centre. --> </div> </body>
Adding multiple images for share button og:image tags
I try to do include multiple og:image meta properties to associate multiple images with my page. According to Facebook's Open Graph protocol documentation, you have only put multiple og:image tags in the html head. That's what I did but unfortunately it doesn't work. I would be pleased, if anyone could give me a hint. I have been using the debug page and Facebooks seems to parse it just fine because I see my metatag images: Meta Tag <meta property="og:title" content="United Serbian Soccer Club" /> Meta Tag <meta property="og:description" content="United Serbian Soccer Club" /> Meta Tag <meta property="og:url" content="http://www.unitedserbians.com" /> Meta Tag <meta property="og:image" content="http://www.unitedserbians.com/images/USSC_futsal_tournament_2016.png" /> Meta Tag <meta property="og:image" content="http://www.unitedserbians.com/images/anualindoortournament2016/FKCZ_MKE_open_winner.jpg" /> Even see the images in the og:image Open Graph properties section, however it always takes only first image and ignores others. Here is currently my main HTML code: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml"> <head> <title>United Serbians</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="icon" href="images/USSC_logo_icon.png" type="image/x-icon"/> <link href="css/style.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="css/coin-slider.css" /> <style type="text/css"> body { background-image: url(images/main_bg.jpg); } a:link { color: #DF0000; } </style> <link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="js/cufon-yui.js"></script> <script type="text/javascript" src="js/droid_sans_400-droid_sans_700.font.js"></script> <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="js/script.js"></script> <script type="text/javascript" src="js/coin-slider.min.js"></script> <script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> <meta property="fb:admins" content="20312314" /> <meta property="og:title" content="United Serbian Soccer Club" /> <meta property="og:description" content="United Serbian Soccer Club" /> <meta property="og:url" content="http://www.unitedserbians.com" /> <meta property="og:image" content="http://www.unitedserbians.com/images/USSC_futsal_tournament_2016.png" /> <meta property="og:image" content="http://www.unitedserbians.com/images/anualindoortournament2016/FKCZ_MKE_open_winner.jpg" /> </head> You can see an example page here: http://www.unitedserbians.com/
Chrome thinks English Language site is Turkish
I'm testing a very simple site — it's a placeholder site mostly built on graphics — and when I just loaded it in Chrome, the Chrome toolbar tells me the pages is in Turkish and asks if I'd like to translate. I can't find anything in the code that could be causing this. I'm just going to put it all up here since there's not much of it. Below is the page code in its entirety, with brand names changed. (There's nothing in the brand names that indicates to me they'd be interpreted as Turkish). <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Acme Vineyards ℘ Sonoma County</title> <meta name="description" content="Acme Vineyards: Farming with Purpose in Sonoma County, California"> <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, width=device-width"> <link rel="stylesheet" href="normalize.min.css"> <link rel="stylesheet" href="main.css"> <!--[if lt IE 9]> <script src="js/vendor/html5-3.6-respond-1.1.0.min.js"></script> <![endif]--> </head> <body> <nav> <ul><!-- before adding anchor tags, uncomment the :hover lines in main.less --> <li id="durell">Marnell Vineyard</li> <li id="gaps-crown">Gap’s End Vineyard</li> <li id="dupont">Acme Vineyard</li> <li id="wilson">Smith Vineyard</li> <li id="one-sky">One Star Vineyard</li> </ul> </nav> <div class="main-container"> <h1>Acme Vineyards: Farming with Purpose in Sonoma County</h1> </div> <div class="footer-container"> <footer> <dl id="phone"> <dt class="office">Office: </dt><dd class="office">555-555-5555</dd> <dt class="fax">Fax: </dt><dd class="fax">555-555-5555</dd> </dl> <ul id="mail"> <li id="email">info#acmevineyards.com</li> <li>PO Box 55555, Sonoma, CA 95555</li> </ul> </footer> <p id="credits">Site Design: Acme Design </div> <div id="badge"></div> </body> </html>
Use <meta> tags to instruct chrome about the content and ignore translating <meta charset="UTF-8" /> <meta name="google" content="notranslate"> <meta http-equiv="Content-Language" content="en" />
This question had luck with adding these meta properties to force Chrome to not attempt translation: <meta charset="UTF-8" /> <meta name="google" content="notranslate"> <meta http-equiv="Content-Language" content="en" />
Your issue is this ℘ Looks like a turkish character to me!