noahcoad / google-spell-check

Uses Google Search spelling magic to fix words or phrases for Sublime Text.
122 stars 18 forks source link

The package works only when the user gets the Google's results in English #14

Open kipu44 opened 10 years ago

kipu44 commented 10 years ago

The instruction: match = re.search(r'(?:Showing results for|Did you mean|Including results for)[^\0]?<a.?>(.*?)', html) finds something only if results are shown in English. When user is e.g. from Poland, (s)he gets the text 'Czy chodziło Ci o' instead of 'Did you mean' and the instruction shown above doesn't find anything. In my opinion, searching for '<span class="spell ng">' from '<span class="spell ng">Did you mean:</span>' or something similar would be much safer and universal.

<span class="spell ng">Did you mean:</span> screenshot from 2014-05-09 23 15 20 <span class="spell ng">Czy chodziło Ci o:</span> screenshot from 2014-05-09 23 15 35

FRVisser commented 9 years ago

&hl=en has to be added to the url to make it work international.

Replace:

html = self.get_page('http://www.google.com/search?q=' + urllib2.quote(text))

With:

html = self.get_page('http://www.google.com/search?q=' + urllib2.quote(text) + '&hl=en')