php - How to get everything between two tags if the closing tag appears in the parent? -



php - How to get everything between two tags if the closing tag appears in the parent? -

this problem: script utilize stops looking @ first tag.

i'm sceaping website, , part of site want 'extract'.

<div class="i-want-this-div"> <div class="annoying-sub-div"> bla bla bla </div> <div class="annoying-sub-div"> etc... </div> <div class="annoying-sub-div"> </div> <div class="annoying-sub-div"> </div> <div class="annoying-sub-div"> </div> </div>

i want display 'annoying'(because mess function of script beingness there) divs on site, how do this?

this current approach: position of first tag, position of closing tag , subtract part form entire string holds whole website source.

$startpos = strpos($siteiamscreaping, '<div class="i-want-this-div">'); $endpos = strpos($siteiamscreaping, '</div>', $startpos) + 8; $annoyingdivs = substr($siteiamscreaping, $startpos, $endpos-$startpos);

the problem is: want stop on main divs closing tag , not on first closing tag finds.

use querypath (or phpquery) simplicity. can extract <div> content class or id easily:

print htmlqp($page)->find("div.i-want-this-div")->html();

php screen-scraping

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -