Domanda

here I want to ask a question regarding curl. I have a url, this could be anything, in which I have to curl specific div, with the help of regex and preg_match. Currently I use the following regex:

    $regex = '/\<div id=\'main\'\>(.*?)<\/div\>/is';

This fetched all the contents of this div, but the problem is here. When there are many nested div, inside this 'main' div, then if there any other closing div tag appeared , than this would stop curling.

What I need is, fetching div, till all the contents of this particular div are fetched and then stopped curling, not when there appeared any other closed div tag.

È stato utile?

Soluzione

you can use this simple html dom parser for your needs

PHP Simple HTML DOM Parser

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top