php - How do you search by the contents of a tag in simplehtmldom? -
I am trying to write a web scraper using simplehmldom. I want to get a tag by searching the content of the tag, it's plain text inside it, not the type of tag once after that I search for the content of my plain text and I want to get the next tag after that. I am
How do I get a tag based on its contents? And once I have this, how do I get the following tags?
Any help would be appreciated.
Thank you.
The following will enable you to search all text nodes, then get the next tag:
< Pre> // Use Simple_HTML_DOM Special selector to retrieve all the text nodes from the 'text' // document $ textNodes = $ html- & gt; Search ('text'); $ Base tag = null; Foreign currency ($ textNodes as textNode) {if ($ textNode-> plain text == 'Hello World') {// Get the parent of the text node / (A text node is always her child / Is its container) $ FoundTag = $ textNode- & gt; mother-father (); break; }} If ($ foundTag) {$ nextTagAfter = $ foundTag-> Next_sabilling (); }
This is not your first question about using the basic Simple_HTML_DOM
. You probably want to
Comments
Post a Comment