Click to See Complete Forum and Search --> : Hiding source


Pembar
06-26-2009, 02:54 AM
Has anyone noticed that google search pages seem to have a different source code?

Here's what you can try.

1. Goto www.google.com
2. Type in any word, I tried "rugby" or "american football"
3. Wait for the page to load, then look for certain words or phrases in the search results. Then look at the source code and do a find, you won't be able to find those words, yet you see them right in front of you.


Anyone knows how google does it? Shouldn't the source code be exactly what you see on the screen?

coothead
06-26-2009, 07:03 AM
Hi there Pembar,

the phrases are there in the "Source code" but some times they have HTML
rendering which would give the impression that the phrase is not in there...
With international <em>rugby</em> rankings
...is just one example.

coothead

Pembar
06-26-2009, 07:27 AM
Strange, I've tried it a couple times and I honestly don't see it. (Same for both IE and FF).

One thing I noticed, when I "view source", I only get to see a part of the entire source code, the HTML starts off correctly with <HTML> but the last code in there is </script>, it doesn't have </body></html> at all.

Charles
06-26-2009, 12:04 PM
Google's HTML is pretty bad but not that bad. Both the start and end tags for HTML, HEAD and BODY elements are completely optional. Google is omitting them as is their right.

Charles
06-26-2009, 12:05 PM
<!doctype html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Google
</title>
<script>window.google={kEI:"5P5ESs6fMpy6ePuK5IoC",kEXPI:"17259",kCSIE:"17259",kHL:"en",j:{en:1,l:function(){},e:function(){},b:location.hash&&location.hash!="#",pl:[]},pageState:"#",timers:{load:{t:{start:(new Date).getTime()}}}};(function(){for(var d=0,c;c=["ad","p","pa","zd","ac","pc","pah","ph","zc"][d++];)(function(b){google.j[b]=function(){google.j.pl.push([b,arguments])}})(c)})();
window.google.sn="webhp";window.google.timers={load:{t:{start:(new Date).getTime()}}};try{window.google.pt=window.gtbExternal&&window.gtbExternal.pageT()||window.external&&window.external.pageT}catch(b){}
window.google.jsrt_kill=1;
</script>
<style>body,td,a,p,.h{font-family:arial,sans-serif}.h{color:#36c;font-size:20px}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}#gbar{height:22px;padding-left:0px}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#gbi,#gbs{background:#fff;left:0;positi on:absolute;top:24px;visibility:hidden;z-index:1000}#gbi{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:1001}#guser{padding-bottom:7px !important;text-align:right}#gbar,#guser{font-size:13px;padding-top:1px !important}@media all{.gb1,.gb3{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}.gb2{display:block;padding:.2em .5em}a.gb1,a.gb2,a.gb3{color:#00c !important}.gb2,.gb3{text-decoration:none}a.gb2:hover{background:#36c;color:#fff !important}
</style>
<script>var _gjwl=location;function _gjuc(){var b=_gjwl.href.indexOf("#");if(b>=0){var a=_gjwl.href.substring(b+1);if(/(^|&)q=/.test(a)&&a.indexOf("#")==-1&&!/(^|&)cad=h($|&)/.test(a)){_gjwl.replace("/search?"+a.replace(/(^|&)fp=[^&]*/g,"")+"&cad=h");return 1}}return 0}function _gjp(){!(window._gjwl.hash&&window._gjuc())&&setTimeout(_gjp,500)};
google.y={};google.x=function(e,g){google.y[e.id]=[e,g];return false};function sf(){try{!google.j.b&&document.f&&document.f.q.focus()}catch(e){}}
window.clk=function(b,c,d,e,f,g,h){if(document.images){var a=encodeURIComponent||escape;(new Image).src=["/url?sa=T",c?"&oi="+a(c):"",d?"&cad="+a(d):"","&ct=",a(e||"res"),"&cd=",a(f),b?"&url="+a(b.replace(/#.*/,"")).replace(/\+/g,"%2B"):"","&ei=","5P5ESs6fMpy6ePuK5IoC",g].join("")}
return true};
window.gbar={qs:function(){},tg:function(e){var o={id:'gbar'};for(i in e)o[i]=e[i];google.x(o,function(){gbar.tg(o)})}};</script>
</head>
<body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload="sf();if(document.images){new Image().src='/images/nav_logo4.png'}" topmargin=3 marginheight=3>
<textarea id=csi style=display:none></textarea>
<script>if(google.j.b)document.body.style.visibility='hidden';</script>
<iframe src="" name=wgjf style="display:none" onload="google.j.l()" onerror="google.j.e()">
</iframe>
<textarea id=wgjc style=display:none></textarea>
<textarea id=csi style=display:none></textarea>
<textarea id=hcache style=display:none></textarea>
<span id=main>
<span id=ghead>
<div id=gbar>
<nobr>
<b class=gb1>Web</b>
<a href="http://images.google.com/imghp?hl=en&tab=wi" onclick=gbar.qs(this) class=gb1>Images</a>
<a href="http://video.google.com/?hl=en&tab=wv" onclick=gbar.qs(this) class=gb1>Video</a>
<a href="http://maps.google.com/maps?hl=en&tab=wl" onclick=gbar.qs(this) class=gb1>Maps</a>
<a href="http://news.google.com/nwshp?hl=en&tab=wn" onclick=gbar.qs(this) class=gb1>News</a>
<a href="http://www.google.com/prdhp?hl=en&tab=wf" onclick=gbar.qs(this) class=gb1>Shopping</a>
<a href="http://mail.google.com/mail/?hl=en&tab=wm" class=gb1>Gmail</a>
<a href="http://www.google.com/intl/en/options/" onclick="this.blur();gbar.tg(event);return !1" aria-haspopup=true class=gb3><u>more</u> <small>▼</small></a>
<div id=gbi>
<a href="http://groups.google.com/grphp?hl=en&tab=wg" onclick=gbar.qs(this) class=gb2>Groups</a>
<a href="http://books.google.com/bkshp?hl=en&tab=wp" onclick=gbar.qs(this) class=gb2>Books</a>
<a href="http://scholar.google.com/schhp?hl=en&tab=ws" onclick=gbar.qs(this) class=gb2>Scholar</a>
<a href="http://www.google.com/finance?hl=en&tab=we" onclick=gbar.qs(this) class=gb2>Finance</a>
<a href="http://blogsearch.google.com/?hl=en&tab=wb" onclick=gbar.qs(this) class=gb2>Blogs</a>
<div class=gb2>
<div class=gbd>
</div>
</div>
<a href="http://www.youtube.com/?hl=en&tab=w1" onclick=gbar.qs(this) class=gb2>YouTube</a>
<a href="http://www.google.com/calendar/render?hl=en&tab=wc" class=gb2>Calendar</a>
<a href="http://picasaweb.google.com/home?hl=en&tab=wq" onclick=gbar.qs(this) class=gb2>Photos</a>
<a href="http://docs.google.com/?hl=en&tab=wo" class=gb2>Documents</a>
<a href="http://www.google.com/reader/view/?hl=en&tab=wy" class=gb2>Reader</a>
<a href="http://sites.google.com/?hl=en&tab=w3" class=gb2>Sites</a>
<div class=gb2>
<div class=gbd>
</div>
</div>
<a href="http://www.google.com/intl/en/options/" class=gb2>even more &raquo;</a>
</div>
</nobr>
</div>
<div id=guser width=100%>
<nobr>
<a href="/url?sa=p&pref=ig&pval=3&q=http://www.google.com/ig%3Fhl%3Den%26source%3Diglk&usg=AFQjCNFA18XPfgb7dKnXfKz7x7g1GDH1tg">iGoogle</a> |
<a href="https://www.google.com/accounts/Login?hl=en&continue=http://www.google.com/">Sign in</a>
</nobr>
</div>
<div class=gbh style=left:0>
</div>
<div class=gbh style=right:0>
</div>
</span>
<span id=body>
<center><br clear=all id=lgpd>
<img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276 id=logo onload="window.lol&&lol()">
<br>
<br>
<form action="/search" name=f>
<table cellpadding=0 cellspacing=0>
<tr valign=top>
<td width=25%>&nbsp;</td>
<td align=center nowrap>
<input name=hl type=hidden value=en>
<input autocomplete="off" maxlength=2048 name=q size=55 title="Google Search" value="">
<br>
<input name=btnG type=submit value="Google Search" onclick="this.checked=1">
<input name=btnI type=submit value="I'm Feeling Lucky" onclick="this.checked=1"></td>
<td nowrap width=25% style="font-size:x-small;text-align:left">&nbsp;&nbsp;
<a href=/advanced_search?hl=en>Advanced Search</a>
<br>&nbsp;&nbsp;
<a href=/preferences?hl=en>Preferences</a>
<br>&nbsp;&nbsp;
<a href=/language_tools?hl=en>Language Tools</a></td>
</tr>
</table>
</form>
<br>
</center>
</span>
<span id=footer>
<center>
<br>
<font size=-1>
<a href="/intl/en/ads/">Advertising&nbsp;Programs</a> -
<a href="/services/">Business Solutions</a> -
<a href="/intl/en/about.html">About Google</a>
</font>
<p>
<font size=-2>&copy;2009 -
<a href="/intl/en/privacy.html">Privacy</a>
</font>
</p>
</center>
</span>
</span>
<script>function _gjp() {!(location.hash && _gjuc()) && setTimeout(_gjp, 500);}google.j[1]={cc:[],co:['ghead','body','footer','xjsi'],pc:[],nb:0,css:document.getElementsByTagName('style')[0].innerHTML,main:'<span id=ghead></span><span id=body></span><span id=footer></span><span id=xjsi></span>'};</script>
<script>function wgjp(){var xjs=document.createElement('script');xjs.src='/extern_chrome/OzgK0dwM7rU.js';(document.getElementById('xjsd') || document.body).appendChild(xjs)};</script>
<div id=xjsd>
</div>
<div id=xjsi>
<script>if(google.y)google.y.first=[];if(google.y)google.y.first=[];if(!google.xjs){google.dstr=[];google.rein=[];window.setTimeout(function(){var a=document.createElement("script");a.src="/extern_js/f/CgJlbhICdXMrMAo4IEAILCswDjgFLCswFjgMLCswFzgDLCswGDgELCswGTgDLCswHTgKLCswJTjJiAEsKzAmOAQsKzAnOAEsKzAq OAAsKzArOAIs/eT3jvDeQRDw.js";(document.getElementById("xjsd")||document.body).appendChild(a)},0);
google.xjs=1};google.y.first.push(function(){function ac_home(){google.ac.i(document.f,document.f.q,'','')}ac_home();google.rein.push(function(h){h&&ac_home()})});google.xjs&&google.j&&google.j.xi&&google.j.xi()</script>
</div>
<script>(function(){
function a(){google.timers.load.t.ol=(new Date).getTime();google.report&&google.report(google.timers.load,{ei:google.kEI,e:google.kCSIE})}if(window.addEventListener)window.a ddEventListener("load",a,false);else if(window.attachEvent)window.attachEvent("onload",a);google.timers.load.t.prt=(new Date).getTime();
})();
</script>

sneakrnet
08-18-2009, 01:21 PM
I just found this thread while researching this very issue, specifically with regard to Google search results page.

You are indeed correct that the links, and the associated text, are not in the code for the page.

The reason I'm concerned about this is that I noticed in Firefox that when I click on a link in the Google results page, I'm being redirected through some other link before arriving at my destination.

I don't know if Google is doing this, or if some malware has gotten onto my system.

I noticed that this is only happening to me in Firefox, not Internet Explorer 8 (though I've been having problems loading pages in IE8, which got me using Firefox in the first place).

I ran identical Google searches in both Firefox (v3.52, by the way, and running in Firefox safe mode) and in IE8. The resulting IE8 page code was similar to what you might expect, with all of the links explicit in the page code. The Firefox code was similar to what you have described and posted.

A quick (15 minute) look at the generated page code tells me that the search results are being stored in an array, or possibly externally (there is a reference to a .js file; the code is obscure -- no doubt purposely), and the links and much of the text is being written on the fly.

Writing javascript code on the client side, within the browser, is not a new trick; if you use a script and use the write (I think it's document.writeln, but I don't have time to look it up right now -- I need to finish this up and go), whatever you write will be written into the page at that point, as if it had been static text (including possibly HTML) downloaded from the server.

Beware if you decide to do this that if someone has javascript turned off in his/her browser, this technique won't work.

In fact, if you turn off javascript in your browser and retry the example that you've described in this thread, you'll discover that the web page source code will be what you probably expected it to be, with all the HTML code explicitly spelled out.

Now I just need to figure out if it's Google rewriting the code, or if it's something even more sinister (even if it's Google, it's sinister, because I'm being redirected through an intermediate link without being forewarned).

Anyway, good luck, and you're not crazy. The full HTML is being hidden from you.

Tom