Я хочу получить значение тега для всех страниц моего сайта. я пытаюсь запустить скрипт только в домене своего веб-сайта и получить все ссылки на страницы моего веб-сайта и их заголовки.
$html = file_get_contents('http://xxxxxxxxx.com');
//Create a new DOM document
$dom = new DOMDocument;
//Parse the HTML. The @ is used to suppress any parsing errors
//that will be thrown if the $html string isn't valid XHTML.
@$dom->loadHTML($html);
//Get all links. You could also use any other tag name here,
//like 'img' or 'table', to extract other tags.
$links = $dom->getElementsByTagName('a');
//Iterate over the extracted links and display their URLs
foreach ($links as $link){
//Extract and show the "href" attribute.
echo $link->nodeValue;
echo $link->getAttribute('href'), '
';
}
Я получаю следующее: z2 я получаю z1.html и z2 ....
мой z1.html имеет заголовок с именем z3. я хочу получить z1.html и z3, а не z2. Кто-нибудь может мне помочь?
Я хочу получить значение тега для всех страниц моего сайта. я пытаюсь запустить скрипт только в домене своего веб-сайта и получить все ссылки на страницы моего веб-сайта и их заголовки.
Это мой код:< /p>
[code]$html = file_get_contents('http://xxxxxxxxx.com'); //Create a new DOM document $dom = new DOMDocument;
//Parse the HTML. The @ is used to suppress any parsing errors //that will be thrown if the $html string isn't valid XHTML. @$dom->loadHTML($html);
//Get all links. You could also use any other tag name here, //like 'img' or 'table', to extract other tags. $links = $dom->getElementsByTagName('a');
//Iterate over the extracted links and display their URLs foreach ($links as $link){ //Extract and show the "href" attribute. echo $link->nodeValue; echo $link->getAttribute('href'), ' '; } [/code]
Я получаю следующее: [url=z1.html]z2[/url] я получаю z1.html и z2 .... мой z1.html имеет заголовок с именем z3. я хочу получить z1.html и z3, а не z2. Кто-нибудь может мне помочь?