Code Monkey home page Code Monkey logo

crawld's Introduction

crawld

Image crawler

Requirements

  • Background service
  • RESTful API
  • Crawl Search URL for product URLs based on search criteria
  • Actual images should not be downloaded, store all image URLs, remove any duplicate images
  • Sets of images should be kept together
  • URLs should be stored without duplicates
  • Needs to scale across distributed hosts

Setup

  1. go get github.com/PuerkitoBio/goquery
  2. go get golang.org/x/net/html
  3. go get github.com/go-redis/redis

go build

Usage

./crawd

Command line flags override crawld.json

Design

There are 2 sets of URLs tracked:

  1. product page URL
  2. product image URL

URLs must be persisted such that multiple runs of crawld does not cause redundant crawling.

API

Endpoint Parameters
GET /api/images Retrieves image from unfiltered queue
POST /api/models Creates a model record in database

Product URLs

This essentially stores all the product URLs found by the crawler, this should be persisted over time so if this tool is run multiple times, state can be resumed. Lookups to see if this URL has been accessed already should be fast. The schema for this store should be simple, basically store the URL with no duplicates.

We use 2 datatypes for this, redis set and redis list.

Data Structure Description Name
Redis Set Guarantees uniqueness, fast lookup crawld.urls.products
Redis List Work queue crawld.queue.products

Image URLs

This stores all the image URLs, there should be no duplicates, sets of images should be grouped together. Should differentiate thumbnail from full size images. Each image URL should allow a simple rating.

Data Structure Description Name
Redis Set Guarantees uniqueness crawld.urls.images
Redis List Work queue crawld.queue.images
Sqlite3 Query-able Tags

Queries

  1. Highest rating, based on categories
  2. Latest photos

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.