Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Simple HTML Dom Parser problem: failed to open stream: HTTP request failed! HTTP/1.0 404
d0m1n1k_
post 1.11.2015, 03:23:43
Post #1





Grupa: Zarejestrowani
Postów: 208
Pomógł: 3
Dołączył: 13.07.2009
Skąd: Tarnów

Ostrzeżenie: (0%)
-----


Witam,
chciałem aby za pomocą poniższego skryptu i biblioteki Simple HTML Dom wyciągnąć linki zgodne z poszukiwanym ze mną schematem.
Mój skrypt:

  1. include('../simple_html_dom.php');
  2. $handle = fopen("_get_links.php", "r");
  3. if($handle){
  4. while(($line = fgets($handle)) !== false){
  5.  
  6. $html = file_get_html($line);
  7. foreach($html->find('a') as $element){
  8. $linkx = $element->href;
  9. if (strpos($linkx,'http://wybrana.domena/produkt/') !== false){
  10. echo $linkx . "<br />";
  11. }
  12. }
  13. }
  14. fclose($handle);
  15. }else{
  16. echo "<br />Error";
  17. }


Pierwsza linijka jest przetwarzana poprawnie.
Niestety, już druga i kolejna nie działa :-//

Wywala następujący błąd:



  1. Warning: file_get_contents( ) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in C:\WebServ\httpd-users\0016-elena_parser\simple_html_dom.php on line 75
  2.  
  3. Fatal error: Call to a member function find() on a non-object in C:\WebServ\httpd-users\0016-elena_parser\app\index.php on line 11


Gdzie:
http://wybrana.domena/produkty/?search%5Bo...Aasc&page=2 - drugi link w pliku _get_links.php
index.php - nazwa pliku ze skryptem


--------------------
Prywatna koncepcja pasji - SprawdzAuto.info
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
viking
post 1.11.2015, 06:41:02
Post #2





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Przecież masz odpowiedź w kodzie: 404 Not Found
Kolejne to już następstwo.


--------------------
Go to the top of the page
+Quote Post
Comandeer
post 1.11.2015, 08:10:13
Post #3





Grupa: Zarejestrowani
Postów: 1 268
Pomógł: 254
Dołączył: 11.06.2009
Skąd: Świętochłowice

Ostrzeżenie: (0%)
-----


Od razu warto zwrócić uwagę na to, że Simple DOM Parser jest niesamowicie przestarzały i nierozwijany. Lepiej używać DOM wbudowanego w PHP


--------------------
Go to the top of the page
+Quote Post
d0m1n1k_
post 1.11.2015, 19:05:55
Post #4





Grupa: Zarejestrowani
Postów: 208
Pomógł: 3
Dołączył: 13.07.2009
Skąd: Tarnów

Ostrzeżenie: (0%)
-----


Ale gdy uprościć skrypt do:

  1. include('../simple_html_dom.php');
  2. $line = "http://www.adres1.com/zmienne&wiecejzmiennych&cos_tam_jeszcze";
  3. $html = file_get_html($line);
  4. foreach($html->find('a') as $element){
  5. $linkx = $element->href;
  6. if (strpos($linkx,'http://wybrana.domena/produkt/') !== false){
  7. echo $linkx . "<br />";
  8. }
  9. }


To z osobna, każda strona jest ładowana poprawnie


--------------------
Prywatna koncepcja pasji - SprawdzAuto.info
Go to the top of the page
+Quote Post
Comandeer
post 1.11.2015, 19:10:09
Post #5





Grupa: Zarejestrowani
Postów: 1 268
Pomógł: 254
Dołączył: 11.06.2009
Skąd: Świętochłowice

Ostrzeżenie: (0%)
-----


A wyświetl sobie po kolei wszystkie linijki czy aby na pewno nie ma w nich jakichś śmieci


--------------------
Go to the top of the page
+Quote Post
Pyton_000
post 1.11.2015, 21:08:49
Post #6





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


file_get_html(trim($line));

questionmark.gif
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 13:17