Digital Point Forums
Winn and Sims

Go Back   Digital Point Forums > Design & Development > Programming > PHP
Google Analytics
Log In to view
your analytics

Reply
 
Thread Tools
  #1  
Old Feb 29th 2008, 10:06 am
Christian Little's Avatar
Christian Little Christian Little is offline
of the Nightfall
 
Join Date: Aug 2006
Location: Vancouver, BC (Canada)
Posts: 1,441
Christian Little is a jewel in the roughChristian Little is a jewel in the roughChristian Little is a jewel in the rough
Search/Matching Code

Here's what I need - to provide a URL and a chunk of HTML to a function, and have it return a boolean if it finds the HTML on the specific page.

So: checklinks($url, $html)

Where:
$url = "http://www.example.com/pagexyz.html";
$html = "<a href=\"http://www.example.com\">Example Link</a> - This is sample description text to go with my link.";

Basically I'm building a script to check if people are keeping their reciprocal links to my sites.

I appreciate the help
Reply With Quote
  #2  
Old Feb 29th 2008, 11:23 am
RoscoeT's Avatar
RoscoeT RoscoeT is offline
Grunt
 
Join Date: Jan 2008
Posts: 64
RoscoeT is on a distinguished road
use the file() function to suck the page into a var.

Then use strpos() or a preg function to check if it is there.
You may also want to check if it is nofollow or not

That is the quick and dirty method. I would use cURL instead and XML DOM functions to test all <a> tags.
That will prevent your code being fooled or throwing false negatives/positives.
Slightly more complicated but works best in my experience.

There are tonnes of scripts around to do what you are looking for. Are you doing this as an exercise to learn or what?
Reply With Quote
  #3  
Old Feb 29th 2008, 7:45 pm
Vbot's Avatar
Vbot Vbot is offline
Champion of the Naaru
 
Join Date: May 2007
Posts: 105
Vbot is on a distinguished road
php Code:
function checklinks($url, $html) {
    $data = file_get_contents($url);
    if(eregi($html, $data))
    {
        return "Match";
    }
    else
    {
        return "No Match";
    }
}
$url = "http://www.example.com/pagexyz.html";
$html = "<a href=\"http://www.example.com\">Example Link</a> - This is sample description text to go with my link.";
echo checklinks($url, $html);
That should do the job.
__________________
PHP Goodies
Reply With Quote
  #4  
Old Mar 1st 2008, 10:30 am
Christian Little's Avatar
Christian Little Christian Little is offline
of the Nightfall
 
Join Date: Aug 2006
Location: Vancouver, BC (Canada)
Posts: 1,441
Christian Little is a jewel in the roughChristian Little is a jewel in the roughChristian Little is a jewel in the rough
Quote:
Originally Posted by RoscoeT View Post
There are tonnes of scripts around to do what you are looking for. Are you doing this as an exercise to learn or what?
Thanks for the help. I'm building a small SEO script that I'm going to use for some clients. In the past I've done most of this manually or bought expensive software. Either way it's a pain and I want to have certain custom features, so I'm building my own from scratch but I have limited php knowledge (i.e. I've hacked wordpress and made a few simple apps, but that's about it), so I'm learning as I go
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Matching the adsense code to my site better mikey1090 Placement / Reviews / Examples 3 Dec 11th 2007 8:20 am
Search code Problem Alistair ASP 2 Apr 13th 2007 1:25 pm
Broad matching vs Exact matching? wzl Yahoo Search Marketing 3 Aug 21st 2006 3:20 am
Website stats not matching Yahoo search stats CDavis Pay Per Click Advertising 0 Nov 16th 2005 10:16 pm
Can you use the Adsense search code forr froogle and local search? crazyhorse AdSense 2 Apr 16th 2005 5:47 am


All times are GMT -8. The time now is 8:09 pm.