简体   繁体   中英

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

i want to parse from this exact line of code <a class="Icon IconDownload" href="javascript: void(0);" isfilelink="true" data-key="K7YyNbVScsvMSS3WNzAzNzEyMjWyiLc0NjY1NrfEFIk3MjA0jzcwjDfSK0hJU7IGAA==" <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.

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'];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM