M
M
MrFrumpuSs2022-03-04 03:33:24
PHP
MrFrumpuSs, 2022-03-04 03:33:24

What is the best way to write a parser (PHP)?

You need to write a parser that will go through the pages of a news site and parse articles along with their content.
What is best to use for parsing, DiDOM will do?
Just how should a parser be written so that there is no 500 error?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rPman, 2022-03-04
@rPman

The modern web is more about javascript and not about generating pages on the backend (and often both), plus for site analysis it can be easier to work with the dom in the browser by opening the page and synjecting your code, for example, with tempermonkey or with selenium
. So it all depends on your target site
On the topic, if you need to parse html directly to php, then I recommend simple_html_dom , simple convenient ... but it failed with aliexpress pages (this site struggles with parsers, even if you take the page after javascript), you can use the lower-level DOMDocument::loadHTMLFile , which is less convenient but less restrictive

A
Alexander Karabanov, 2022-03-04
@karabanov

How to scrape any site?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question