I've been having issues accessing websites and just realized that since the websites are controlled by my company I need to add a step in my script that shows the webpage I have my companies proxy IP or Im on their server. I hope that makes sense. For example if I access my companies webpage on my personal computer it says "Safari cant find server", but if I am logged into my company laptop I have no problems.
I know that I need to inject my proxy in phantomjs. Angel P suggested I use
--proxy=address:port specifies the proxy server to use (e.g. --proxy=192.168.1.42:8080).
--proxy-type=[http|socks5|none] specifies the type of the proxy server (default is http).
--proxy-auth specifies the authentication information for the proxy, e.g. `--proxy-auth=username:password).
I just don't understand how to add that into my script.
Script below
import os
import subprocess
#PJS_PATH = './phantom/bin/phantomjs'
#service_args = [
#'--proxy=idname:port#',
#'--proxy-type=http'
#]
#proxies = {'https': 'http://idname:port#'}
APP_ROOT = os.path.dirname(os.path.realpath(__file__))
CASPER = "C:/casperjs/bin/casperjs"
SCRIPT = os.path.join(APP_ROOT,'FCM.js')
params = CASPER +' '+ SCRIPT
print(subprocess.check_output(params,shell=True))
Where does the proxy go? I've gone to here, but don't understand how to compose it.
here is what you will need to add to casperjs to help it work. Along with Artjom B advice hope this helps someone.
You can easily join the
service_args
to get a string:and put that before the script: