プロキシを使うには?

ショコラ
ショコラ

プロキシを使うには?

curl、wget、PHP のサンプルでキメマス。

もっさん先輩
もっさん先輩

①curl版

curl -L {アクセスするURL} --proxy {プロキシのIP}:3128

②wget版

wget -e HTTP_PROXY={プロキシのIP}:3128 {アクセスするURL}

③PHP版

$context = stream_context_create(
  ['http'=>
    ['proxy'=>'tcp://{プロキシのIP}:3128']
  ]);
echo file_get_contents('{アクセスするURL}',false,$context);

④PHP版(Array)

$context = stream_context_create(
  array('http'=>
    array('proxy'=>'tcp://{プロキシのIP}:3128')
  ));
echo file_get_contents('{アクセスするURL}',false,$context);
Scroll to Top