-1

My requirement is to lookup all the CSS content (external, internal and inline) from a given URL for some specific CSS content. I am currently using the 'PHP Simple HTML DOM Parser' to lookup HTML. But is there a specific way I can achieve this for CSS, specifically, all types of CSS ?

Thanks in advance :)

8
  • 1
    What do you mean by "lookup all the CSS content for some specific CSS content" - do you mean finding out every rule that applies to a certain element? Commented Jan 23, 2012 at 23:27
  • well.. ya.. something like, find if 'font-size: 0;' exists . Commented Jan 23, 2012 at 23:29
  • 2
    This is not trivial. What do you need it for, what is your end goal? Commented Jan 23, 2012 at 23:35
  • you would find all of the link nodes that are css, use those links to grab the css files, then you would have to write some code to parse the css files (have fun with that), and match rules to nodes in the original html file. sounds like a good amount of work. especially the css parsing. out of curiosity, why would you want to do this? Commented Jan 23, 2012 at 23:36
  • find if a page is SEO friendly.. Given any URL, find all the DOs and DONT's in terms of SEO. Commented Jan 23, 2012 at 23:36

1 Answer 1

1

It is possible to gather all CSS a HTML document includes (style attributes and elements) and links (link element, type CSS).

However, as far as I know, some CSS parser in PHP exists so far (but no interface to CSSOM). So you would be able to gather all CSS, but you would need to write/integrate a parser for CSS on your own.

Keep in mind that some sites use things like less which is then turned into CSS via javascript, so you might want to integrate less into PHP as well. Same applies for other, client-side CSS technologies.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.