Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> simple_html_dom zapis do bazy, jak zapisać
michalbd93
post
Post #1





Grupa: Zarejestrowani
Postów: 60
Pomógł: 0
Dołączył: 23.11.2017

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


  1. $html = file_get_contents('https://www.strona.pl');
  2. //Create a new DOM document
  3. $dom = new DOMDocument;
  4.  
  5. //Parse the HTML. The @ is used to suppress any parsing errors
  6. //that will be thrown if the $html string isn't valid XHTML.
  7. @$dom->loadHTML($html);
  8.  
  9. //Get all links. You could also use any other tag name here,
  10. //like 'img' or 'table', to extract other tags.
  11. $links = $dom->getElementsByTagName('a');
  12.  
  13. //Iterate over the extracted links and display their URLs
  14. foreach ($links as $link){
  15. // tutaj chce zapisać do bazy danych informacje normalnie sie wyswitlają ale nie zapisuje do bazy
  16. }
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
michalbd93
post
Post #2





Grupa: Zarejestrowani
Postów: 60
Pomógł: 0
Dołączył: 23.11.2017

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


  1. <?php
  2. require("simple_html_dom.php");
  3.  
  4. $html = file_get_contents('https://www.wp.pl');
  5. //Create a new DOM document
  6. $dom = new DOMDocument;
  7.  
  8. //Parse the HTML. The @ is used to suppress any parsing errors
  9. //that will be thrown if the $html string isn't valid XHTML.
  10. @$dom->loadHTML($html);
  11.  
  12. //Get all links. You could also use any other tag name here,
  13. //like 'img' or 'table', to extract other tags.
  14. $links = $dom->getElementsByTagName('a');
  15.  
  16. //Iterate over the extracted links and display their URLs
  17. foreach ($links as $link){
  18.  
  19. //Extract and show the "href" attribute.
  20. echo $link->getAttribute('href');
  21.  
  22. }
  23.  
  24. ?>

powiedzmy ze to jest cały kod i chciał bym te wyniki z $link zapisać do bazy
mam połączenie z baza danych ale jak chce tam zapisać to wyskakuje bład
Catchable fatal error: Object of class DOMElement could not be converted to string in /prz/index.php on line 35


mam nadzieję że dobrze opisałem

Ten post edytował michalbd93 2.12.2018, 18:20:55
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 6.10.2025 - 22:34