Mam problem z parsowaniem pewnej strony. Jak dla innych działa to w przypadku 50style dostaje komunikat o błędzie:
file_get_contents(https://50style.pl): failed to open stream: HTTP request failed!
lub
DOMDocument::loadHTMLFile(https://50style.pl): failed to open stream: HTTP request failed!
W pierwszym rzucie używałem simple hml dom:
Kod
<?php
include_once('simple_html_dom.php');
$page='https://50style.pl';
function parsePage($url){
$html = file_get_html($url);
foreach($html->find('a[plaintext*=Regulamin]') as $a)
echo $a->href . "\n";
}
$test=parsePage($page);
?>
include_once('simple_html_dom.php');
$page='https://50style.pl';
function parsePage($url){
$html = file_get_html($url);
foreach($html->find('a[plaintext*=Regulamin]') as $a)
echo $a->href . "\n";
}
$test=parsePage($page);
?>
Drugie podejscie to przykład:
Kod
<?php
$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTMLFile('https://50style.pl');
libxml_clear_errors();
foreach( $doc->getElementsByTagName('a') as $item){
$href = $item->getAttribute('href');
echo $href. "<br>";
}
?>
$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTMLFile('https://50style.pl');
libxml_clear_errors();
foreach( $doc->getElementsByTagName('a') as $item){
$href = $item->getAttribute('href');
echo $href. "<br>";
}
?>
nie wiem co z tym zrobić :/