googleTitleSearch
For a while now, I’ve been using Jake’s googleTitleSearch macro to auto-populate the “see also” links after my posts. But I’ve been noticing more and more that all the links that Google is offering for some titles are the same – particularly when I link to articles at sites which operate on multiple URLs. I’m sure Google will sort out this problem eventually, but in the meantime I’ve made a few changes to the macro so that if I create a link for a post, it will do a google search on what is related to that, instead.
The macro, with my changes highlighted:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | on googleTitleSearch (adrpost) {
local (htmltext = "");
if defined (adrpost^.title) or defined (adrpost^.link) {
try {
local (adrSearchResult = @adrpost^.googleTitleSearchResult);
if not defined (adrSearchResult^) {
if defined (adrpost^.link) {
adrSearchResult^ = google.search ("related:" + adrpost^.link)};
if not defined (adrSearchResult^) or adrSearchResult^.searchComments == "Sorry, no content found for this URL" {
adrSearchResult^ = google.search (adrpost^.title)}};
local (adr);
for adr in @adrSearchResult^.resultElements {
try {
local (url = adr^.url);
local (title, tooltip);
if sizeOf (adr^.directoryTitle) > 0 {
title = adr^.directoryTitle}
else {
title = adr^.title};
title = searchEngine.stripMarkup (title);
title = string.replaceAll (title, "...", "");
title = string.trimWhiteSpace (title);
if sizeOf (adr^.summary) > 0 {
tooltip = searchEnging.stripMarkup (adr^.summary)}
else {
tooltip = searchEngine.stripMarkup (adr^.snippet)};
tooltip = string.replaceAll (tooltip, """, """);
htmltext = htmltext + "<a href="" + url + "" title="" + tooltip + "">" + title + "</a> | "}}};
if sizeOf (htmltext) > 0 {
htmltext = string.mid (htmltext, 1, sizeOf (htmltext) - 3)}};
return (htmltext)} |