Skip to content

Commit

Permalink
fix add_proxy_pool
Browse files Browse the repository at this point in the history
  • Loading branch information
laike9m committed Mar 8, 2016
1 parent d6a8148 commit ba7279e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions test/zhihu-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,12 +780,8 @@ def test_anonymous():

def test_proxy():
# visit http://cn-proxy.com/ to get available proxies if test failed
proxy_ips = ('112.25.41.136', '180.97.29.57')
proxies = [
{'http': proxy_ips[0]},
{'http': proxy_ips[1]}
]
client.set_multiple_proxies(proxies)
proxy_ips = ['112.25.41.136', '180.97.29.57']
client.set_proxy_pool(proxy_ips)
for _ in range(5):
result = client._session.get('http://httpbin.org/ip').json()
assert result['origin'] in proxy_ips
Expand Down
2 changes: 1 addition & 1 deletion zhihu/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def set_proxy_pool(self, proxies, auth=None):
from functools import partial
from random import choice

self.proxies = proxies
self.proxies = [{'http': p, 'https': p} for p in proxies]

def get_with_random_proxy(url, **kwargs):
proxy = choice(self.proxies)
Expand Down

0 comments on commit ba7279e

Please sign in to comment.