screen scraping - simplehtmldom php: How do you search for one thing or another -
I want to scrape some html with simplehtmldom in php. My tag is a bunch of tag containg I want an alternative between bgcolor = # ffffff and bgcolor = #cccccc There are some tags that have other BGolders.
I want to get all the code in each tag, which is either bgcolor = # ffffff or bgcolor = # cccccc. I can not use just $ html-> '(tr') because there There are other tags that I do not want to find.
Any help would be appreciated.
You can load the DOM in the simplexml class and then use xpath, such as:
$ Xml = simplexml_import_dom ($ simple_html_dom); $ Gift = $ xml - & gt; Xpath ('// [@ bgcolor = "#ffffff"] | // [@ bgcol = "#cccccc"]');
Maybe you can put a single set of brackets or a syntax, but I have to check twice.
Update:
Sorry, I thought you were talking about the DOM extension. I thought the simplest HTML, and it seems that its search feature is based on XPath. Why not:
$ gift = $ html -> find ('[bgcolor = # ffffff], [bgcolor = "# cccccc]');
Comments
Post a Comment