I would like to write my own set of PHP scripts that would enable me to check the position of a given URL in a search engine based on some keywords. You know the kinda thing. There's quite a few about, like on JimTools.
I just don't understand the theory behind it, or infact what the theory is, come to mention it!
I'm having difficulty finding any info on this.
Any idea where I might start or some search terms to look for or perhaps some PHP tutes?
In it's simplest form:
- Analyse the URL of a SERP to decipher what format the query is passed to the engine, plus any other parameters (results per page, starting point etc)
- Construct a valid URL using your own search terms
- Collect the SERP using something like fopen() - I'm not 100% on which function, as I do this kind of thing in Perl (LWP) rather than PHP
- Parse the page you've collected, using regular expressions to find URLs in the SERP
- Check if the URL you're looking for matches up
That, in a nutshell, is it. The tricky part is in constructing a regex to parse out the URLs - this can get quite complicated eg my one for AV is something like
@<a.*?rn true;">(.*?)</a>(.*?)<span class=x>\s*?URL: (.*?)\s*?@gi