0

I want to know any algorithms or php code for working out keyword competition. The keyword can be used multiple sites per website and on multiple websites. I want to know how its ranking can be worked out.

Thanks

Speedy Wap
  • 478
  • 4
  • 7
  • 18
  • 2
    you want us to build you a search engine? – dqhendricks Jan 09 '11 at 17:29
  • @dqhendricks - "you should get the idea" - I like how we are expected to do this for him ha – sethvargo Jan 09 '11 at 17:34
  • This is really two questions; you may have 1 "problem" but you need to separate distinct questions. Your second question here isn't worth asking in a new question (it's been [answered](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454) and would likely be closed as a duplicate pretty quickly). To that end, I'd suggest editing this question and removing your second paragraph. – Mark Elliot Jan 09 '11 at 18:26
  • @seth.vargo I like how you feel that I expected you to do this for me. I expected people willing to help to help me. You could have rather given me the answer and I would have said thank you. – Speedy Wap Jan 09 '11 at 18:30

2 Answers2

0

You want a search engine? That's a pretty ambitious task. Quite a lot to ask over a volunteer driven PHP thread. Since I'm a nice guy, I'll give you the Regex for free, but you'll have to do some digging to build that search engine you want.

/<title>([^<])*</title>/gi

If you really are serious about the SE, try starting with this article from O'Rilley.

Bailey Parker
  • 15,599
  • 5
  • 53
  • 91
  • 1
    i wouldn't use a regex for getting a title tag. instead I would use the PHP DOM classes to parse html, and grab the title contents. – dqhendricks Jan 09 '11 at 17:50
  • @dqhendricks, why not? php dom might not deal with broken title tags. – Speedy Wap Jan 09 '11 at 18:15
  • @phpmycoder, i am not building a search engine (bit too far fetched for me right now), I have my website domainsoutlook.com where I am doing keyword analysis for websites and just need to analyse keywords for that. – Speedy Wap Jan 09 '11 at 18:16
  • 1
    @user381595 you should never try to parse a structured language with regex... here is a rather famous answer as to why http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – dqhendricks Jan 09 '11 at 18:18
  • @dqhendricks Point taken. In this application, I think the overhead of loading a PHP DOM class and parsing a document for one lousy title tag is a little too much. Besides, the regex won't break unless the code is invalid, which would cause the DOM interpreter to break too. – Bailey Parker Jan 09 '11 at 18:20
  • @dqhendricks Ironically, most of the open source PHP DOM interpreter classes use regexes to parse. This is not true of PHP DOM or libxml. – Bailey Parker Jan 09 '11 at 18:33
  • @PhpMyCoder: I think you'll find most parsers of any kind use regular expressions somewhere, but HTML is not a regular language and cannot be parsed with regex alone. The point is that you need to deal with nesting. ...and most modern parsers can deal with some malformed code. – Mark Elliot Jan 09 '11 at 18:40
0

Try get_meta_tags

Example #2 What get_meta_tags() returns (taken from the manual)

<?php
// Assuming the above tags are at www.example.com
$tags = get_meta_tags('http://www.example.com/');

// Notice how the keys are all lowercase now, and
// how . was replaced by _ in the key.
echo $tags['author'];       // name
echo $tags['keywords'];     // php documentation
echo $tags['description'];  // a php manual
echo $tags['geo_position']; // 49.33;-86.59
?>
Cups
  • 6,901
  • 3
  • 26
  • 30