代理在Curl不工作通过执行,但在命令行


Proxy In Curl Not Working Via Exec, But Does In Command line

所以我试图使用一个随机代理从我的代理列表文本文件我得到一个卷曲。

这里是我拉文件的地方,所以你可以得到一些上下文:http://orcahub.com/proxy-list/

这只是一个带有代理列表的txt文件。

无论如何,我有一个脚本格式的curl请求随机代理

当我只是回显格式,然后复制并粘贴输出到命令行时,它工作得很好,但当我执行时,我得到一个奇怪的错误。

sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 16: syntax error: unexpected end of file

这是我当前的代码

    $f_contents = file("cleanedxml4.txt");
    $line = $f_contents[array_rand($f_contents)];
    $data = $line;
    $pieces = explode(" ", $data);
    $woah = $pieces[0];
    $loah = $pieces[1];

        $f_contents = file("proxies_265.txt");
    $line = $f_contents[array_rand($f_contents)];
    $data = $line;
    $format = 'curl '.$loah.' -d ''<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
<methodName>pingback.ping</methodName>
<params>
 <param>
  <value>
   <string>'.$url.'</string>
  </value>
 </param>
 <param>
  <value>
   <string>'.$woah.'</string>
  </value>
 </param>
</params>
</methodCall>''';
$data = preg_replace( "/'r|'n/", "", $data);
$format = $format . " --proxy " . $data . " -m 5";
$format = 'bash -c "exec nohup setsid ' . $format . ' > /dev/null 2>&1 &"';
exec($format);
//echo $format . "'n'n";

嗯,xml在你的代码中这么多是什么好主意?以下是我在大学服务器上的工作(不支持curlopt):

exec('curl -s --connect-timeout '.$this->_connect_timeout.' -x '.$ip.':'.$port.' '.$this->_target_url.' > '.$hide.' 2>&1');

可以看到,我将输出保存到服务器上的隐藏文件中,这符合我的scraper需求(我的问题在这里)。