Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
A Go web-crawler course project that scrapes a dating site into Elasticsearch with singleton, concurrent, and distributed architectures.
Crawler-website is a Go web-crawler project, built as the hands-on companion to the Imooc course 'Google资深工程师深度讲解Go语言' (coding.imooc.com/class/180.html), that scrapes profile records from the dating site zhenai.com, stores them in Docker-run Elasticsearch, and serves a searchable HTML frontend on localhost:8888.
Crawler-website is a web crawler written entirely in Go that demonstrates three successive architectures — singleton, concurrent, and distributed — for collecting structured user profiles from a seed website (http://www.zhenai.com/zhenghun). It takes HTML pages from the seed site as input, parses them with golang.org/x/net/html, and produces indexed records in Elasticsearch (run via docker run -d -p 9200:9200 elasticsearch) that are then queryable through a web frontend. The project was created for the Chinese Go course taught by a Google senior engineer on Imooc, and the repository is public on GitHub with 62 stars.
gopkg.in/olivere/elastic.v5 client.ItemSaver.go --port=1234), worker services (worker.go --port=9000 and --port=9001), and a coordinating main.go that accepts --itemsaver_host and --worker_hosts flags.src/crawler/frontend/starter.go launches an HTML search page on port 8888 implementing the MVC pattern.女 && Age>20 or 男 && 已购车 to filter crawled profiles by gender and other attributes.golang.org/x/text, golang.org/x/net/html, and the gopm package manager to fetch them.src/crawler/main.go and src/crawler/frontend/starter.go, then browse to http://localhost:8888/.ItemSaver.go on port 1234, two worker.go instances on ports 9000 and 9001, and run main.go with --itemsaver_host=":1234" --worker_hosts=":9000,:9001".女 && Age>20 or 男 && 已购车 in the frontend to filter profiles by demographics and purchase status.The crawl pipeline follows the README's runbook. First, start Docker and execute docker run -d -p 9200:9200 elasticsearch to get a search instance. Then, in concurrent mode, run src/crawler/main.go to crawl the seed website and src/crawler/frontend/starter.go to serve the results; in distributed mode, launch the item-saver and two worker services before running the coordinating main.go. Finally, open http://localhost:8888/ and enter a query string.
The repository is a public GitHub project associated with a paid Imooc course ('Google资深工程师深度讲解Go语言'). The code itself is free to browse and run if you have Go, Docker, and the listed dependencies installed.
The frontend accepts REST-style query strings that combine field conditions with the && operator, for example 女 && Age>20 and 男 && 已购车. Conditions are evaluated against the indexed profile fields stored in Elasticsearch.
The Elasticsearch container listens on port 9200, the web frontend on port 8888, the distributed item-saver on port 1234, and the distributed worker services on ports 9000 and 9001.
The README lists golang.org/x/text, golang.org/x/net/html, github.com/gpmgo/gopm, and gopkg.in/olivere/elastic.v5. Packages are fetched with go get and the gopm tool (gopm get -g -v golang.org/x/text).
Only Elasticsearch is run inside Docker (docker run -d -p 9200:9200 elasticsearch); the crawler, worker, item-saver, and frontend programs are Go binaries you run directly from a terminal.
