Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8537381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:53:20+00:00 2026-06-11T10:53:20+00:00

I have been using the following script to create sitemaps for my clients websites.

  • 0

I have been using the following script to create sitemaps for my clients websites. The issue is it does not work for every site. I have found that many if not all the sites hosted on godaddy do not spider. If anyone can see an error in my script or know what is causing the fault I would greatly appreciate the help.

Thanks in advance

set_time_limit(0);
class spider_man
{
var $url;
var $limit;
var $cache;
var $crawled;
var $banned_ext;
var $domain;

function spider_man( $url, $banned_ext, $limit ){
    $this->domain = $url;
    $this->url = 'http://'.$url ;
    $this->banned_ext = $banned_ext ;
    $this->limit = $limit ;
    if( !fopen( $this->url, "r") ) return false;
    else $this->_spider($this->url);
}

function _spider( $url ){
    $this->cache = @file_get_contents( urldecode( $url ) );
    if( !$this->cache ) return false;
    $this->crawled[] = urldecode( $url ) ;
    preg_match_all( "#href=\"(https?://[&=a-zA-Z0-9-_./]+)\"#si", $this->cache, $links );
    if ( $links ) :
        foreach ( $links[1] as $hyperlink ){                
            if(strpos($hyperlink,$this->domain)===false){ break; }
            else{
                $this->limit--;
                if( ! $this->limit ) return;
                if( $this->is_valid_ext( trim( $hyperlink ) ) and !$this->is_crawled( $hyperlink ) ) :
                $this->crawled[] = $hyperlink;
                echo "Crawling $hyperlink<br />\n";
                unset( $this->cache );
                $this->_spider( $hyperlink );
                endif;
            }
        }
    endif;
}

function is_valid_ext( $url ){   
    foreach( $this->banned_ext as $ext ){
        if( $ext == substr( $url, strlen($url) - strlen( $ext ) ) ) return false;
    }
    return true;
}
function is_crawled( $url ){
    return in_array( $url, $this->crawled );
}
}

$banned_ext = array(".dtd",".css",".xml",".js",".gif",".jpg",".jpeg",".bmp",".ico",".rss",".pdf",".png",".psd",".aspx",".jsp",".srf",".cgi",".exe",".cfm");

$spider = new spider_man( 'domain.com', $banned_ext, 100 );
print_r( $spider->crawled );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:53:22+00:00Added an answer on June 11, 2026 at 10:53 am

    When you access a site using fopen() of file_get_contents() you don’t send AGENT or REFERRER or other header information. It’s blatently obvious that this is an automated script.

    You need to look at sending context with your fopen (check the docs and read the context section) or, better still, using CURL. This allows you to set the agent and referrer headers to simulate a browser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following the standard instruction for using AES algorithm, I have not been able to
I have been using the following sort: var query = _cityRepository.GetAll( .OrderBy(item => item.RowKey.Substring(0,
I have been using the following CSS to apply an effect at the bottom
I have been using the following to add a dynamic link on a page
I am using the following code for the Share Price Application I have been
I have been following the following post on using multiple ItemTemplates in a ListView
I have been doing some research for using MSMQ. Following 2 gave me fundamental
I have the following script to create a table in MySQL version 5.1 which
I am using the following script to create a tarball of a directory with
I am using the following script to post data to an external site. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.