GithubHelp home page GithubHelp logo

slmndr's Introduction

Salamander

A minimalistic ruby web crawling framework.

Installation

To install Salamander, simply invoke the following command on your console:

gem install slmndr

Usage

To use Salamander, all you need to do is call the Salamander::crawl method, like so:

require 'slmndr'

# list of URLs to start from
urls = [ "http://www.google.com/" ]
# list of optional arguments
args = {
	visit: lambda do |url|
		return true # a lambda which accepts a URL and returns true if that URL should be visited
	end,
	delay: 1, # a positive float indicating the number of seconds between requests in one thread
	threads: 1, # a positive integer indicating the number of allowed simultaneous requests to the target web asset
	agent: "Mozilla/5.0 (MSIE 9.0; Windows NT 6.1; Trident/5.0)" # the user-agent string to use for requests
}
# call the crawl method
Salamander::crawl(urls, args) do |request, response, depth|
	# request:  The URL string used to request the current page
	# response: A hash containing data pertaining to the response to the requested URL
	#     base_uri:         The base_uri field of OpenURI's response
	#     meta:             The meta field of OpenURI's response
	#     status:           The status field of OpenURI's response
	#     content_type:     The content_type field of OpenURI's response
	#     charset:          The charset field of OpenURI's response
	#     content_encoding: The content_encoding field of OpenURI's response
	#     last_modified:    The last_modified field of OpenURI's response
	#     body:             Contains the body of OpenURI's response
	# depth:    A positive integer indicating the breadth/depth of the current page, relative to one of the seed URLs
	puts "Just visited #{request}"
end

Proxy

To use a proxy, simply set your HTTP_PROXY and HTTPS_PROXY environment variables.

Author(s)

  • John Lawrence M. Penafiel (penafieljlm)

Homepage

slmndr's People

Contributors

penafieljlm avatar

Watchers

James Cloos avatar  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.