GithubHelp home page GithubHelp logo

hhy5277 / sitemap-generator-crawler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vezaynk/sitemap-generator-crawler

0.0 1.0 0.0 95 KB

Script that generates a sitemap by crawling a given URL

Home Page: https://www.knyz.org

License: MIT License

PHP 100.00%

sitemap-generator-crawler's Introduction

Sitemap Generator

Features

  • Actually crawls webpages like Google would
  • Generates a seperate XML file which gets updated every time the script gets executed (Runnable via CRON)
  • Awesome for SEO
  • Crawls faster than online services
  • Verbose logging
  • Completely usable through CLI
  • Color support in CLI mode
  • Customizable
  • Author is active on Github, open an issue for support
  • Literally the best open-source sitemap script written in PHP
  • Non-restrictive licensing

Usage

Usage is pretty strait forward:

  • Configure the crawler by modifying the config section of the sitemap.php file
    • Select the file to which the sitemap will be saved
    • Select URL to crawl
    • Configure blacklists, accepts the use of wildcards (example: http://example.com/private/* and *.jpg)
  • Generate sitemap
    • Either send a GET request to this script or use it from the CLI as seen below
    • A sitemap will be generated and saved
    • Submit to Google
  • For better results
    • Setup a CRON Job to execute the php script

CLI Usage

Sometimes you need to run the script for a large number of domains (If you are a webhost for example). This sitemap generator allows you to override any variable on-the-fly in CLI.

Basic usage

Scan http://www.mywebsite.com/ and output the sitemap to /home/user/public_html/sitemap.xml:

php sitemap.php file=/home/user/public_html/sitemap.xml site=http://www.mywebsite.com/

Advanced usage

While the above is the most common use-case, sometimes you need to modify other things such as $debug or $blacklist. I will do a bit of explaining about how shells work so you don't mess up.

Lets start with the blacklist which is a one-dimensional array. This is how you would pass an array as a GET request.

php sitemap.php blacklist[]="foo"&blacklist[]="bar"

Shells are different however as [] is parsed as a shell expansion and & as a fork-to-background. You want neither of those things. As such, you want to escape both of them resulting in the following:

php sitemap.php blacklist\[]="foo"\&blacklist\[]="bar"

Next, let's tackle the $debug variable. All the same concepts apply but the syntax is slightly different:

php sitemap.php debug\["add"]=true\&debug\["warn"]=false\&debug\["reject"]=true

Important note: Overriding an array does exactly what it means. Previously defined elements are destroyed.

Running Tests

Acknowledgements

This section is devoted as a thank you for everybody who helped create this script.

Richard Leishman and Web Forward for the regex at the heart of the script.
Anatoli Nicolae for fixing a bug in the regex
Mario Bouchard for fixing #32 and #35 with his first pull request
Santeri Kannisto from 2 Global Nomads for a number of features and many, many bug reports

License

MIT License

Copyright (c) 2017 Slava Knyazev <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

sitemap-generator-crawler's People

Contributors

anatolinicolae avatar erandelax avatar jandanielcz avatar mbouchard avatar mrl22 avatar vezaynk avatar villfa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.