Coder Social home page Coder Social logo

craigslist-ruby-crawler's Introduction

Craigslist Ruby Keyword Crawler

This Ruby script, generally speaking, allows you to crawl Craigslist (throughout most cities around the world listed on CL) and parse the results for specific keywords you are looking for. Upon completion, it spits out the results to an HTML file in a directory called 'output'.

Run Time

The run time, if you run it with the default values, can be anywhere from 1000 - 4,500 seconds (i.e. 16 minutes to 1.25 hrs).

Getting it Running Responsibly

To verify that it works on your machine, or in your environment, any at all - you may want to reduce the amount of items parsed to say 10, down from 701, by modifying the line:

Original:

first_items = list[0..700]

To:

first_items = list[10..20]

If it runs with no issues, you are free to increase it back to the original numbers.

Note that your ISP may object to you repeatedly running a crawler from your home internet connection. So if they come a knocking, I am not responsible.

Modifying Keywords

The master array that stores all the 'useful' links is called posts. By useful I mean the links that correspond to the gigs found that have your specified keywords.

To change the keywords that are searched, you will want to look for the lines:

posts.each do |i|
  if i[1] =~ /keyword|(some keyword combo)/i
    some_array << i
  end
end

Although I am sure you are aware, the =~ operator is a regular expression operator.

To read about how Ruby handles and this operator, check out the RegExp docs here.

The HTML generation is handled by Nokogiri.

Additional Files

I have included some sample output HTML files in their respective directories.

Left to do

  • This is a pretty crude script, that is not very DRY. So generally DRYing it up.
  • Increase efficiency - so script runs in less time.
  • Re-factor to make adding keywords for multiple languages easier than duplicating a ton of code.
  • Parse and store cities examined - along with the keywords in those cities (ideally, it would be good if we could answer the question "How many Rails posts in Chicago?")
  • Adding tests

craigslist-ruby-crawler's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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