Skip to content

Instantly share code, notes, and snippets.

@whiteleaf7
Created February 3, 2017 07:00
Show Gist options
  • Save whiteleaf7/d728269bc8cabc561cdd3dc878cc583c to your computer and use it in GitHub Desktop.
Save whiteleaf7/d728269bc8cabc561cdd3dc878cc583c to your computer and use it in GitHub Desktop.
プロキシ
def get_toc_source
toc_url = @setting["toc_url"]
return nil unless toc_url
max_retry = 5
toc_source = ""
cookie = @setting["cookie"] || ""
proxy = ["http://YOUR_PROXY_IP:PORT", "user", "password"]
open_uri_options = make_open_uri_options("Cookie" => cookie, allow_redirections: :safe, proxy_http_basic_authentication: proxy)
begin
open(toc_url, open_uri_options) do |toc_fp|
if toc_fp.base_uri.to_s != toc_url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment