Search engine spiders usually visits and crawls websites/webpages and then indexes and saves them in their database. It measures the website/webpage carefully and checks title, content, links, images, HTML codes etc and then it ranks the website on the basis of these measurements in search engine.