curl - Using proxies in PhantomJS with PHP PhantomJS library -


the documentation phantomjs show how use proxies. however, how is used in php when using library php phantomjs?

for matter, how of phantomjs addons used?

i'm doing curl use proxies:

curl_setopt($curl, curlopt_proxy, "http://$proxy:$port"); curl_setopt($curl, curlopt_proxyuserpwd, "$username:$password"); 

i'd exact same thing phantomjs. have installed , configured , example works (php pantomjs's own example).

use jonnyw\phantomjs\client;  $client = client::getinstance(); $request  = $client->getmessagefactory()->createrequest(); $response = $client->getmessagefactory()->createresponse(); $request->setmethod('get'); $request->seturl('http://jonnyw.me');  $client->send($request, $response); print_r($response); 

where proxy info go here?

thanks. i'm new phantomjs.

from official php phantomjs documentation, section "phantomjs options". can add options running phantomjs binary this:

<?php      use jonnyw\phantomjs\client;      $client = client::getinstance();     $client->getengine()->addoption('--load-images=true');     $client->getengine()->addoption('--ignore-ssl-errors=true'); 

so add proxy information this:

    $client->getengine()->addoption("--proxy=$proxy:$port");     $client->getengine()->addoption("--proxy-auth=$username:$password"); 

there option proxy type (http|socks5|none):

    $client->getengine()->addoption("--proxy-type=socks5"); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -