Episode 17 - Escaping multi-word searches

Vlcsnap-2010-05-08-14h19m37s105

Click on image above for a preview

Released: May 08, 2010, Running time: 15 min

In this episode:

We escape multi-word search terms before querying Google Blog Search.

Tags: rspec, model

FREEWatch episode

Downloads

Item Size
Quicktime MP4 (H.264, AAC, 1024x768) 93.48 MB
iPhone (H.264, AAC, 432x320) 23.73 MB
Windows Media (WMV 9, WMA 9, 1024x768) 85.83 MB
  • Share

Search terms that have multiple words in them are causing Ruby’s open-uri to raise an exception. It is not just multi-word search terms which will trigger this, but any search terms that have strange characters in them.

Since we are querying Google Blog Search by making a GET request with the search term embedded in the URL, we must make sure the term is properly escaped.

There is no need to escape search terms for querying Twitter because we are using the twitter gem for this, which takes care of all the escaping for us.

Screenshots

  • Vlcsnap-2010-05-08-14h19m47s207
  • Vlcsnap-2010-05-08-14h24m06s232
  • Vlcsnap-2010-05-08-14h25m15s154
  • Vlcsnap-2010-05-08-14h26m17s11
  • Vlcsnap-2010-05-08-14h27m36s28
  • Vlcsnap-2010-05-08-14h30m02s213
  • Vlcsnap-2010-05-08-14h31m41s177

No comments yet

Commenting is disabled.