Jump to content
Sign in to follow this  
rotube

Ajutor Simple Html Dom

Recommended Posts

rotube    0
<div class="thumb"><script>document.write(xv.thumbs.replaceThumbUrl('<a href="/video-2zvvw93/real_teacher_and_student"><img src="https://img-hw.xvideos.com/videos/thumbs169xnxx/1a/f5/65/1af565fa0885ae2ee85283707b04f4ed/1af565fa0885ae2ee85283707b04f4ed.7.jpg" id="pic_5033516" onload="xv.thumbs.mgr.load(5033516)" onerror="xv.thumbs.mgr.fail(5033516)" /></a>'));</script></div>

Cum as putea prelua de mai sus :

 

1. img src

2. id=

 

Am incercat asa dar nu merge :

    foreach($html->find('div[class="thumb"] script') as $ts) {
    echo $ts->find('img',0)->src . '<br>';
    }

 

Share this post


Link to post
Share on other sites
Erase    16

($html->find('div[class="thumb"]') as $ts)

 

tip: sa te asiguri ca atributul sa fie scris in element inainte sa citesti

Edited by Erase

Share this post


Link to post
Share on other sites
Sim Master    108

Avand in vedere ca imaginile sunt injectate dinamic in pagina, nu poti folosi modulele pentru HTML DOM din PHP. Va trebui sa le iei cu regex.

 


preg_match_all('/<img src="(.*)" id="(pic_(.*?))" (.*) \/>/', $page_contents, $matches);
$imgs = [
    'src' => $matches[1],
    'id' => $matches[2]
];

print_r($imgs);

  • Thanks 1
  • Upvote 2

Share this post


Link to post
Share on other sites
rotube    0
8 hours ago, Sim Master said:

Avand in vedere ca imaginile sunt injectate dinamic in pagina, nu poti folosi modulele pentru HTML DOM din PHP. Va trebui sa le iei cu regex.

 

 


preg_match_all('/<img src="(.*)" id="(pic_(.*?))" (.*) \/>/', $page_contents, $matches);
$imgs = [
    'src' => $matches[1],
    'id' => $matches[2]
];

print_r($imgs);

 

Merge perfect. Multumesc mult.

Share this post


Link to post
Share on other sites
DoubleG    41

Gecko a scris un tutorial destul de bun despre Regex:

 

cand e vorba de stealing data de pe site-uri, regex-ul e cel mai bun.

 

  • Downvote 1

Share this post


Link to post
Share on other sites
ManutaDeAur    123
1 hour ago, DoubleG said:

cand e vorba de stealing data de pe site-uri, regex-ul e cel mai bun.

 

vorbești prostii

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×