Skip to content

Instantly share code, notes, and snippets.

@jaturken
Last active July 1, 2017 15:20
Show Gist options
  • Save jaturken/09db897fe071f9e70737 to your computer and use it in GitHub Desktop.
Save jaturken/09db897fe071f9e70737 to your computer and use it in GitHub Desktop.
Curl + useragents
def special_request(url)
user_agents = ['Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:39.0) Gecko/20100101 Firefox/39.0', 'Mozilla/5.0 (Windows NT 6.1; rv:35.0) Gecko/20100101 Firefox/35.0', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36']
data = Curl.get(url) do |http|
http.ssl_verify_peer = false
http.headers["User-Agent"] = user_agents.sample
end
data.perform
data.body_str
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment