Posts: 1,000
Threads: 253
Joined: Feb 2008
Is there any way to use google to check the spelling of things without opening a web browser?
Like can I send a search word to google, and then grab the HTML result of the query then check for a "Did you mean:" then reply back to my program the corrected part?
It's just an idea. Does anyone know if it can be done?
Thanks,
Jimmy Vig
Posts: 1,000
Threads: 253
Joined: Feb 2008
The first part is possible...
str SearchWord="joey figjiani"
SearchWord.findreplace(" " "+")
str url.format("http://www.google.com/search?hl=en&q=%s" SearchWord)
HtmlDoc d.InitFromWeb(url)
str s=d.GetHtml
out s
The "Did you mean:" is right here in the HTML there in this section:
<DIV class=med id=res>
<H2 class=hd>Search Results</H2>
<DIV>
<OL>
<LI>
<P><FONT class=p color=#cc0000>Did you mean: </FONT><A class=p href="/search?hl=en&ie=UTF-8&sa=X&oi=spell&resnum=1&ct=result&cd=1&q=joey+figgiani&spell=1">joey <B><I>figgiani</I></B></A>
Now to just grab "Joey Figgiani" instead of "Joey Figjiani"
Do you think this would be against Google's policy or anything?
Posts: 1,000
Threads: 253
Joined: Feb 2008
Well...I think I have it figured out!
Spell Check with google "Did you mean:"
out
str SearchWord="Joey Figjiani"
str GoogleWord=SearchWord
GoogleWord.findreplace(" " "+")
str url.format("http://www.google.com/search?hl=en&q=%s" SearchWord)
HtmlDoc d.InitFromWeb(url)
str s2=d.GetText("LI")
if _s.get(s2 0 14)="Did you mean: "
,s2.findreplace("Did you mean: " "")
,strrev s2
,s2.findreplace("nwohs stluser 2 poT " "")
,strrev s2
,SearchWord=s2
else
,out "Word had no suggestions:"
out SearchWord