2levelsabove Posted February 3, 2010 Share Posted February 3, 2010 Or this there an easier way? Thanks (I know this is sorta retarded what I am asking) Quote Link to comment https://forums.phpfreaks.com/topic/190833-should-i-use-regex-to-get-website-page-title-tag-description-keywords-contents/ Share on other sites More sharing options...
salathe Posted February 3, 2010 Share Posted February 3, 2010 The answer depends on your proficiencies and the tools available to you. For example, regex might be easier for you to pick up and write a quick script doing what you want (get those tags' contents). For me, it might be easier to use a document parser and access the structure (e.g using Tidy, DOM and friends) to get at the tags' contents. For someone else, get_meta_tags() might work fine (assuming they were not wanting the title!). If you're not comfortable with one method over another (or not aware of others to compare against) then that's also going to come into play with regards to the "easiest" way to do something. Quote Link to comment https://forums.phpfreaks.com/topic/190833-should-i-use-regex-to-get-website-page-title-tag-description-keywords-contents/#findComment-1006367 Share on other sites More sharing options...
2levelsabove Posted February 3, 2010 Author Share Posted February 3, 2010 Thanks a lot for your quick response. One last thing however. What are some document parsers that you like? I know you mentioned Tidy. Any other recommendations? Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/190833-should-i-use-regex-to-get-website-page-title-tag-description-keywords-contents/#findComment-1006374 Share on other sites More sharing options...
salathe Posted February 4, 2010 Share Posted February 4, 2010 I like to use Tidy to clean up the potentially messy HTML (a lot of the web is very messy!) and DOMDocument for parsing into something I can query and get the required information in PHP. There are many branches from there; like Zend Framework's Zend_Dom_Query which uses DOM/XPath behind the scenes. There are even wrappers around regex-scraping if you wanted to go in that direction (but really, don't unless you have very specific reasons to do so). Quote Link to comment https://forums.phpfreaks.com/topic/190833-should-i-use-regex-to-get-website-page-title-tag-description-keywords-contents/#findComment-1006767 Share on other sites More sharing options...
2levelsabove Posted February 4, 2010 Author Share Posted February 4, 2010 Thank you for your timely response. I appreciate it greatly. Quote Link to comment https://forums.phpfreaks.com/topic/190833-should-i-use-regex-to-get-website-page-title-tag-description-keywords-contents/#findComment-1007061 Share on other sites More sharing options...
4rapiddev Posted April 17, 2011 Share Posted April 17, 2011 I've just created an article on How to Parse Title Description Keywords From A Website with PHP and I would like to share: http://4rapiddev.com/php/php-parse-title-description-keywords-from-a-website/ Quote Link to comment https://forums.phpfreaks.com/topic/190833-should-i-use-regex-to-get-website-page-title-tag-description-keywords-contents/#findComment-1202545 Share on other sites More sharing options...
salathe Posted April 26, 2011 Share Posted April 26, 2011 I've just created an article on How to Parse Title Description Keywords From A Website with PHP and I would like to share: http://4rapiddev.com/php/php-parse-title-description-keywords-from-a-website/ That article is a great demonstration of what people should not be doing! As already noted, there are far more robust and useful tools available than hacking together a bunch of regular expressions; so, use those. Quote Link to comment https://forums.phpfreaks.com/topic/190833-should-i-use-regex-to-get-website-page-title-tag-description-keywords-contents/#findComment-1206344 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.