PHP DOM and swaping IPS


PHP DOM and swaping IPS

我想知道是否有一种方法可以使用PHP DOM类(目前使用http://sourceforge.net/projects/simplehtmldom/并且似乎不支持它)并在服务器ip之间切换?

我需要相当于'CURLOPT_INTERFACE',用于curl,但对于DOM在这种情况下,因为我不想使用我的帐户的共享IP,我想使用它的专用IP

只需使用curl下载带有所需选项(和CURLOPT_RETURNTRANSFER)的XML或HTML文档,然后然后用您喜欢的DOM实现对其进行解析,如下所示:

$ch = curl_init('http://example.com/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_INTERFACE, 'eth0');
$content = curl_exec($ch);
$doc = new DOMDocument();
$doc->loadHtml($content);
echo 'Root node is ' . $doc->documentElement->tagName . '!';