我遇到了问题我有一个地理位置限制的网址,只能从欧洲或美国查看。我的位置是亚洲。我想从网址中提取所有href。
但是我使用curl但问题是它发送服务器IP地址,我希望用用户IP地址发出请求,以便跟踪用户访问过的链接。如果您可以指导我如何使用用户IP地址发送请求而不使用curl,我将不胜感激。
以下是源代码。我正在访问的网址是:
http://partnerads.ysm.yahoo.com/ypa/?ct=2&c=000000809&u=http%3A%2F%2Ftrouve.autocult.fr%2F_test.php%3Fq%3Dtarif%2520skoda% 2520superb%2520combi&安培; R =&安培; W = 1&安培;电视=安培; TT =安培; LO =&安培; TY =安培; TS = 1458721731523&安培; AO =安培; H = 1&安培; CONO = 3292b85181511c0a&安培峰; dt = 1&安培; ER = 0安培; SI = p-Autocult_FRA_SERP_2%3A600x796
<?php
include_once 'simple_html_dom.php';
$html = file_get_html('iframe.html');
// find iframe from within html doc
foreach($html->find('iframe') as $iframe)
{
$src = $iframe->getAttribute('src'); // src extracted
$ch = curl_init(); // Initialise a cURL handle
// Set any other cURL options that are required
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36');
curl_setopt($ch, CURLOPT_URL,$src);
$results = curl_exec($ch); // Execute a cURL request
//echo curl_error($ch);
curl_close($ch); // Closing the curl
$bool = TRUE; $match = array(); $int = 0;
while(preg_match('/<a[^>]+href=([\'"])(.+?)\1[^>]*>/i', $results, $matches))
{
if($bool)
{
// print captured group that's actually the url your searching for
echo $matches[2].'<br>'.'<br>'.'<br>'.'<br>';
$bool = false;
}
}
}
答案 0 :(得分:1)
您可以使用代理。
DELETE lh
FROM location_history lh LEFT JOIN
(SELECT Date(expires) as TheDate,
Hour(expires) as TheHour, Max(expires) as MaxTime
FROM location_history
WHERE expires BETWEEN '2016-03-26' and '2016-03-27'
GROUP BY TheDate, TheHour
) lh2
ON lh2.MaxTime = lh.expires
WHERE lh2.MaxTime is null AND
lh.expires BETWEEN '2016-03-26' and '2016-03-27';
没有卷曲:
$ip = '100.100.100.100:234' //example $ip
curl_setopt($ch, CURLOPT_PROXY,$ip);
如果你在寻找代理,那么有些地址很容易被抓住:
$aContext = array(
'http' => array(
'proxy' => 'tcp://'.$ip,
'request_fulluri' => true,
),
);
$cxContext = stream_context_create($aContext);
$sFile = file_get_contents("http://www.google.com", False, $cxContext);
超过2000 ips