M
M
Mikhail5552014-08-20 06:42:47
CMS
Mikhail555, 2014-08-20 06:42:47

What is the best way to parse an HTML page? DOM, preg_math or something else?

In fact, a template engine is needed ... it is understood that a certain php script will output data in HTML format, after parsing the template and inserting the necessary data ... There are a lot of descriptions of various technologies on the network, but each has its drawbacks and each is not advised use!

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alexander Vladimirovich, 2014-08-20
@polyanin

I use this simplehtmldom.sourceforge.net

I
IceJOKER, 2014-08-20
@IceJOKER

also as an option - https://code.google.com/p/phpquery/

M
Mikhail555, 2014-08-20
@Mikhail555

These are all third-party libraries, I somehow already used them ... if you do not use a third-party one, but limit yourself to regular php tools?

_
_ _, 2014-08-20
@AMar4enko

Do you understand your task? I will write what I understood from your confusion:
Am I missing something? If not, what didn't you like about bare PHP? It's like a template engine.

C
Casper Phantom, 2014-08-28
@zcasper

In general, I divide the process into several stages.
I get a page.
through str_pos and substr I get the desired section of the page, restore it through tidy_repair_string ,
and then something like the condition if (!preg_match(...)) { $dom new DomDocument(); ... } here's a diagram...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question