Skip to content

Commit ee4a928

Browse files
committed
v0.1.9 Add httposion get by proxys
1 parent d0c59a3 commit ee4a928

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

.deliver/config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ CLEAN_DEPLOY=true
1010
# prevent re-installing node modules; this defaults to "."
1111
GIT_CLEAN_PATHS="_build rel priv/static"
1212

13-
PRODUCTION_HOSTS="instaghub1 instaghub2 instaghub3 instaghub4"
13+
PRODUCTION_HOSTS="instaghub1 instaghub2 instaghub3"
1414
PRODUCTION_USER="root"
1515
DELIVER_TO="/root/$APP/app_release"
1616

.env_sample

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ export INS_SESSION_ID_GAME="11658585665%3AiJeECzOuOucZmy%3A6"
55
export INS_SESSION_ID_FOOD="11470214398%3AmnKVpyIylVSm3E%3A23"
66
export INS_SESSION_ID_HOT="11658769798%3AKI5EpFWvayXPOP%3A12"
77
export INS_SESSION_ID_OTHER=11658769798%3AKI5EpFWvayXPOP%3A12,11470214398%3AmnKVpyIylVSm3E%3A23
8-
export INS_NOT_LOGIN=0
9-
export INS_GOOGLE_QPS=2
8+
export INS_NOT_LOGIN=1
9+
export INS_GOOGLE_QPS=1
10+
export PROXYS=144.172.97.116:3199,196.17.83.160:3199,196.18.250.226:3199,186.179.27.178:3199,104.144.102.218:3199,196.17.89.123:3199,104.249.4.116:3199,181.177.73.192:3199,196.18.249.242:3199,104.233.53.237:3199

lib/instagram/ins_web_api.ex

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,37 @@ defmodule Ins.Web.API do
166166

167167
defp get(url_part, params) do
168168
headers = generate_header(params)
169+
proxy_option = get_random_proxy()
170+
proxy = if proxy_option != nil do
171+
Logger.debug "use proxy #{proxy_option}"
172+
[{:proxy, proxy_option}]
173+
else
174+
nil
175+
end
169176
Logger.debug "#{inspect headers}"
170177
[url_part, params]
171178
|> build_url
172-
|> HTTPoison.get!(headers)
179+
|> (fn(s) ->
180+
if proxy != nil do
181+
Logger.debug "get with proxy"
182+
HTTPoison.get!(s, headers, proxy)
183+
else
184+
Logger.debug "get without proxy"
185+
HTTPoison.get!(s, headers)
186+
end
187+
end).()
173188
|> handle_response
174189
end
175190

191+
defp get_random_proxy() do
192+
proxys = System.get_env("PROXYS")
193+
if proxys != nil do
194+
proxys |> String.split(",") |> Enum.random
195+
else
196+
nil
197+
end
198+
end
199+
176200
defp generate_header(params) do
177201
if System.get_env("INS_NOT_LOGIN") == "1" do
178202
get_not_login_header(params)

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule Instaghub.MixProject do
44
def project do
55
[
66
app: :instaghub,
7-
version: "0.1.8",
7+
version: "0.1.9",
88
elixir: "~> 1.5",
99
elixirc_paths: elixirc_paths(Mix.env()),
1010
compilers: [:phoenix, :gettext] ++ Mix.compilers(),

0 commit comments

Comments
 (0)