I am not super familiar with PHP, but if you need to do DOM parsing, you are better of using a library. Avoid rolling your own regular expressions like the plague, it will only cause you trouble in the future.
Looking around I found this PHP DOM manipulation library github.com/ivopetkov/html5-dom-document-php/, have never used it, but it looks promising and has a bunch of stars in github. And it seems to have documentation, which is always a plus.
Even if you are using a library, the problem with scraping is that it depends on the layout you are trying to get data from, so if that changes, you need to update your code. Because of that reason, in the past I found that it is better to keep your queries just specific enough to get what you want, in the case the layout changes a little bit, but not too much, you might get away without changing anything on your side.
What does this has to do with C3?