Last active
July 1, 2017 15:20
-
-
Save jaturken/09db897fe071f9e70737 to your computer and use it in GitHub Desktop.
Curl + useragents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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