我想在做DOM解析HTML时隐藏我的IP地址,我刚刚解析了来自其他网站的计划航班,我想隐藏我的ip,所以他们不会禁止我的ip。有人可以帮助我吗?
我不确定我是否正确回答了你的问题。
您需要从网站获取内容(网页抓取)吗?在获取内容之前,设置代理 ip(您可以在 hidemyass 中找到许多代理地址),这样您的真实 ip 就会被隐藏。
试试这个代码:
$withProxy = array(
'http' => array(
'proxy' => 'tcp://221.10.40.238:80',
'request_fulluri' => true,
),
);
$strProxy = stream_context_create($withProxy);
$getPage = file_get_contents("http://www.website.com", False, $strProxy);
您可以在"whatismyip"中测试此代码:您将读取IP代理而不是您的真实IP!
$getPage = file_get_contents("http://www.whatismyip.com/", False, $strProxy);