At the heart of the internet lie spiders (also known as robots or web crawlers). These aren't actual insects, but automated software programs. They discover publicly accessible pages by following links and sitemaps. Some crawlers gather information for search indexes, while others support different applications. Not every crawler indexes everything it encounters.
Imagine a library without a catalogue. A web crawler is a librarian that visits allowed public shelves, reads page titles and discovers links to other shelves. A crawler discovers pages; an indexer organizes information; a search engine answers searches using an index. These are related jobs, not the same thing.
Example: a link written as about.html on https://example.com/ points to https://example.com/about.html. A crawler should not automatically follow links to unrelated sites.
HTTP: the request/response protocol used to retrieve pages. HTML: the markup that describes a web page. URL: an address for a resource. Status 200: a successful HTTP response; 404: the requested resource was not found. Sitemap: a file that can list discoverable URLs. Rate limit: a restriction on how often requests should be made.
robots.txt: published crawl preferences for cooperative robots. It is not a lock, a privacy guarantee, or proof of permission. Authentication, access rules, terms of use and reasonable request rates still matter. A crawler cannot reliably discover every page, and pages rendered by JavaScript may need different handling.
The spider begins with a list of known starting URLs (seeds). It makes an HTTP request to an allowed example page and processes the response, respecting access restrictions and crawl policies.
Once the HTML is retrieved, the spider filters out all <a href="..."> tags. It may discover new URLs from links, add them to a queue, and schedule later requests subject to crawl limits and permissions.
Well-behaved crawlers consult robots.txt and honor applicable rules. However, robots.txt is a voluntary crawling convention, not an access-control or security barrier. Protect private pages with real authentication and server-side restrictions.
Explore a Python crawler example, step by step. This browser workshop only displays code; it never runs Python or sends requests. The example uses https://example.com/, a documentation domain. A real crawler must respect permissions, robots rules, rate limits and terms of use. The downloadable mini-lab below is a runnable local-only, one-page experiment using Python standard-library modules; it is not a production crawler.
π§ͺ Practical experiment: download the included local_spider.py and demo_site/. Start a local server with python3 -m http.server 8765 --bind 127.0.0.1 --directory demo_site, then in another terminal run python3 local_spider.py. It visits only your own demo page, never an external website. Stop the server with Ctrl+C. You can also inspect the code without running it.
# System on standby... Click on step 1 to start the compiler.