我想将网页转换为 leet (1337) 与 XPath 和 PHP 对话。
它可以只用 PHP 完成,但 HTML 节点也被替换为 leet speak。
示例($html 是网页):
$find = array("a","b","c","d","e","f","g","h","i","j"."k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
$repl = array("4","b","c","d","3","f","g","h","1","j","k","1","m","n","0","p","9","r","5","7","u","v","w","x","y","2");
$html = str_replace($find, $repl, $html);
这也替换了 HTML 节点。
这可以通过 XPath 选择器text()使用 XPath 和 PHP 来完成吗?示例($html 是网页):
$dom = new DOMDocument();
$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$xpath->query('//text()');
\\HERE THE REPLACING IN XPATH