carsonyl / pypac

Find and use proxy auto-config (PAC) files with Python and Requests.
https://pypac.readthedocs.io
Apache License 2.0
71 stars 19 forks source link

Is my PACSession setting the wrong proxy string? #40

Closed HsuTimothy closed 5 years ago

HsuTimothy commented 5 years ago

I created a PACSession with a pac url but it seems to be incorrectly setting the proxy as "PROXY proxyIP:port" instead of just using "proxyIP:port".

I've created 2 test cases to illustrate my problem:

from pypac import PACSession, get_pac, download_pac
import requests

url = "https://www.turbotax.intuit.com"
pac_url="https://www.somepacurl.com/pac"
pac = get_pac(url=pac_url, allowed_content_types=['text/plain])

"""
This works
"""
proxy = pac.find_proxy_for_url("https://www.turbotax.intuit.com", "https://www.turbotax.intuit.com")
proxy = proxy.split(" ")[1]

proxies = { 'https': proxy, 'http': proxy }

s = requests.Session()
s.proxies = proxies

r = s.get(url)
print(r.text)

"""
This doesn't work
"""
s = PACSession(pac)
r = s.get(url)
print(r.text)