How to parse anchor javascript void (PHP) with simple.html.dom

Viewed 56

i want to parse from this exact line of code <a class="Icon IconDownload" href="javascript: void(0);" isfilelink="true" data-key="K7YyNbVScsvMSS3WNzAzNzEyMjWyiLc0NjY1NrfEFIk3MjA0jzcwjDfSK0hJU7IGAA==" THE VALUE K7YyNbVScsvMSS3WNzAzNzEyMjWyiLc0NjY1NrfEFIk3MjA0jzcwjDfSK0hJU7IGAA== and i don't know what to do.. Can anyone help me ?

This is what i have done so far:

$html = new simple_html_dom();
$html->load($response);

$anchors = $html->find('.IconDownload[data-key]');

foreach ($anchors as $anchor){
   echo $anchor->plaintext;
}

If i run this i get blank white screen.

2 Answers

This works fine and i get the results that i want

$html = new simple_html_dom();
$html->load($response);

$myArr = [];
foreach ($html->find('table a') as $anchor){

   $myArr[]= $anchor->attr['data-key'];
   $myArr[]= $anchor->attr['data-name'];


}

print_r($myArr);

Try with:

$html = new simple_html_dom();
$html->load($response);

foreach ($html->find('a[class=IconDownload]') as $anchor){
   echo $anchor->attr['data-key'];
}
Related