javascript-php How to parse dom like JS?

Source: Internet
Author: User
JS is for HTML, for example, I want to verify

So with jquery, alert ($ (' #demo_div '). attr (' Display ')), but what if I use server-side PHP to crawl a DOM element in a Web page and then combine CSS to parse its CSS properties? Is there a function or class that has been written?

Reply content:

JS is for HTML, for example, I want to verify

So with jquery, alert ($ (' #demo_div '). attr (' Display ')), but what if I use server-side PHP to crawl a DOM element in a Web page and then combine CSS to parse its CSS properties? Is there a function or class that has been written?

Supplement 3:

Please read the Supplementary 2 and review 7 floor of this question before you "like" the question, and think about whether you should do so.

The landlord's Y problem itself is still possible, but the main problem to make XY problem bad practice, it should be a lesson.

Supplement 2:

All right, you're a problem master!

Noisy for a long time, a short length of two answers, transfer 3 members 6 floor reviews, ask you a half-day you just say what to do!!!

Why didn't you explain your original purpose before?

Typical XY problem--Kezhouqiujian, ask the non-request, must first trouble the community for a half-day to find out your purpose, really little meaning. Master Please read this article first.

I read the question of the main problem of the response, almost all of the problems are negative points, I think the question of the Lord you this problem should be found stepping.

You better go back to reflect on it, read a few more times the wisdom of questioning, less to the community left some inexplicable, wasting time guessing game.

Supplement 1:

You might consider using PHP to call a render core that supports only html+css (without JS) and then take the rendering results. This will at least:

    • Properly tolerate small problems in HTML and get a standard tree-shaped DOM structure
    • Accurately handle CSS overlay relationships to correctly get any CSS properties for a particular element

If you want to do extermination implementation, do not think that only within the framework of PHP to do this thing.

Fully realize your needs, relying solely on any PHP library, can not be killed. any. Not even death. No doubt.

Because of a simple principle: if you only parse the HTML string text of a Web page, we simply cannot tell what state the last property of Demo_div is in.

For example, in your case,displayproperty is used for additional

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.