How to create a request for PHP Simple HTML DOM Parser?

Given the code , it is from the Feed vkontakte:

<h5 class="post_author"><a class="author" href="/kopter_86" data-from-id="7871209" data-post-id="7871209_3485">Назар Добровський</a> <span class="explain">поделился ссылкой</span></h5>

Task : To parse all the values ​​(figures) of data-from-id = "7871209", the output should be the result: 7871209, 4134142, and so on.

First, as a rule, we connect the class and the file.

include ('simple_html_dom.php'); $ html = file_get_html ('test.html');

and then I did not understand, help

  • First, put the code in question - there is a “edit” down there. Secondly, for example, I did not understand what you want. Write better the desired result. - splash58
  • corrected, registered result - Boogeyman
  • Do you want PHP Simple HTML DOM Parser or will you have a DomDocument? - splash58
  • Any option will suit, the main thing that worked - Boogeyman
  • Displays 0, in two cases - Boogeyman

2 answers 2

 // ищем `a` c атрибутом `data-from-id` foreach($html->find('a[data-from-id]') as $a) // выводим. в фигурных скобках с кавычками, потому что имя с дефисами echo $a->{'data-from-id'} . "\n"; 
  • Displays 1 result, and their number in the code is Boogeyman
  • so foreach as a result of find do - splash58
  • Thank you very much splash58, you solved my question which stretched out for two days very quickly) - Boogeyman
  • changed to another test.html began to beat Fatal error: Call to a member function find () on a non-object - Boogeyman

Understood with the error Fatal error: Call to a member function find () on a non-object

It is necessary in simple_html_dom.php define ('MAX_FILE_SIZE', 600000), to change to load larger files