隐私爬虫
Privacy Crawler
我需要你的帮助,谁能解释一下为什么我的代码在网站上找不到 a-tag 隐私 zoho.com?
我的代码在其他网站上很好地找到了 link“隐私”,但在网站上却没有 zoho.com
我使用 symfony 爬虫:https://symfony.com/doc/current/components/dom_crawler.html
// Imprint Check //
function findPrivacy($domain) {
$ua = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13';
$curl = curl_init($domain);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_USERAGENT, $ua);
$data = curl_exec($curl);
$crawler = new Crawler($data);
$nodeValues = $crawler->filter('a')->each(function ($node) {
if(str_contains($node->attr('href'), 'privacy-police') || str_contains($node->attr('href'), 'privacy')) {
return true;
} else {
return false;
}
});
return $nodeValues;
}
如果您查看来自 zoho.com 的源代码,那么您会看到页脚是空的。但是在网站上,如果向下滚动,页脚不是空的。
我现在如何找到这个 link 隐私?
您的脚本无法找到不存在的内容。如果您在浏览器中加载 zoho.com 页面并查看源代码,您会发现甚至没有隐私一词。包含隐私政策 link 的页脚可能是异步加载的,PHP 无法处理。
编辑:通过异步加载我的意思是使用像 AJAX 这样的东西,它只是 client-side。由于 PHP 只是 server-side,它无法执行将包含 link 的页脚加载到隐私政策所需的操作。
我需要你的帮助,谁能解释一下为什么我的代码在网站上找不到 a-tag 隐私 zoho.com?
我的代码在其他网站上很好地找到了 link“隐私”,但在网站上却没有 zoho.com
我使用 symfony 爬虫:https://symfony.com/doc/current/components/dom_crawler.html
// Imprint Check //
function findPrivacy($domain) {
$ua = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13';
$curl = curl_init($domain);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_USERAGENT, $ua);
$data = curl_exec($curl);
$crawler = new Crawler($data);
$nodeValues = $crawler->filter('a')->each(function ($node) {
if(str_contains($node->attr('href'), 'privacy-police') || str_contains($node->attr('href'), 'privacy')) {
return true;
} else {
return false;
}
});
return $nodeValues;
}
如果您查看来自 zoho.com 的源代码,那么您会看到页脚是空的。但是在网站上,如果向下滚动,页脚不是空的。
我现在如何找到这个 link 隐私?
您的脚本无法找到不存在的内容。如果您在浏览器中加载 zoho.com 页面并查看源代码,您会发现甚至没有隐私一词。包含隐私政策 link 的页脚可能是异步加载的,PHP 无法处理。
编辑:通过异步加载我的意思是使用像 AJAX 这样的东西,它只是 client-side。由于 PHP 只是 server-side,它无法执行将包含 link 的页脚加载到隐私政策所需的操作。