Skip to content

Commit

Permalink
[#6] Replace obsolete URI.encode by CGI.escape
Browse files Browse the repository at this point in the history
  • Loading branch information
malparty committed Jun 14, 2021
1 parent aac9dcd commit 21d617b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/services/google_service/client_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class ClientService
require 'httparty'

def self.query(keyword, lang = 'en')
encoded_keyword = URI.encode(keyword)
uri = URI("https://google.com/search?q=#{encoded_keyword}&hl=#{lang}&gl=#{lang}")
escaped_keyword = CGI.escape(keyword)
uri = URI("https://google.com/search?q=#{escaped_keyword}&hl=#{lang}&gl=#{lang}")
user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) '\
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36'
HTTParty.get(uri, { headers: { 'User-Agent' => user_agent } })
Expand Down

0 comments on commit 21d617b

Please sign in to comment.