Skip to content

Instantly share code, notes, and snippets.

@heroinbob
Last active May 6, 2019 21:49
Show Gist options
  • Save heroinbob/8b0b5e68f869b8af1fe6 to your computer and use it in GitHub Desktop.
Save heroinbob/8b0b5e68f869b8af1fe6 to your computer and use it in GitHub Desktop.

Revisions

  1. heroinbob revised this gist Jun 30, 2015. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions carfax_plate_search.rb
    Original file line number Diff line number Diff line change
    @@ -12,14 +12,14 @@
    require 'htmlentities'
    require 'cgi'

    arr = ('A'..'Z').to_a
    possibilities = arr.map { |c| arr.map { |x| "#{c}#{x}" } }
    letters = ('A'..'Z').to_a
    possibilities = letters.product letters
    hits = []

    possibilities.each do |combos|
    combos.each do |combo|
    plate = "XXX#{combo}XXX" # Change to suite your needs!
    response = `curl 'http://www.carfax.com/processQuickVin.cfx?partnerCode=CFX&partnerSiteLocation=Y&checkReport=DEC&checkReportVersion=30&fid=&test=&cctest=&affiliateId=&subId=&bannerName=&partnerCode=CFX&partnerSiteLocation=Y&checkReport=DEC&checkReportVersion=30&fid=&test=&cctest=&affiliateId=&subId=&bannerName=&licensePlateNumber=#{plate}&licensePlateState=CA' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-US,en;q=0.8' -H 'Referer: http://www.carfax.com/'`
    response = `curl -s 'http://www.carfax.com/processQuickVin.cfx?partnerCode=CFX&partnerSiteLocation=Y&checkReport=DEC&checkReportVersion=30&fid=&test=&cctest=&affiliateId=&subId=&bannerName=&partnerCode=CFX&partnerSiteLocation=Y&checkReport=DEC&checkReportVersion=30&fid=&test=&cctest=&affiliateId=&subId=&bannerName=&licensePlateNumber=#{plate}&licensePlateState=CA' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-US,en;q=0.8' -H 'Referer: http://www.carfax.com/'`

    if response =~ /year=(\d{4})&make=(\w+)&model=(.+?)&recordCheckType/
    hits << { plate: plate, year: $1, make: $2, model: $3 }
  2. heroinbob created this gist Jun 25, 2015.
    32 changes: 32 additions & 0 deletions carfax_plate_search.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #
    # Ridiculously basic script to search license plate combinations.
    # I removed the user-agent and cookie headers that I copied from
    # chrome, but if you need them just add your own user-agent and
    # cookie from the carfax site back in.
    #
    # You'll need to change the possibilites, plate pattern and regex
    # to suite your needs. I wrote this in about 5 minutes so it's
    # basic, crude and pretty unmaintainable, but gives you a sense
    # of what can be done.

    require 'htmlentities'
    require 'cgi'

    arr = ('A'..'Z').to_a
    possibilities = arr.map { |c| arr.map { |x| "#{c}#{x}" } }
    hits = []

    possibilities.each do |combos|
    combos.each do |combo|
    plate = "XXX#{combo}XXX" # Change to suite your needs!
    response = `curl 'http://www.carfax.com/processQuickVin.cfx?partnerCode=CFX&partnerSiteLocation=Y&checkReport=DEC&checkReportVersion=30&fid=&test=&cctest=&affiliateId=&subId=&bannerName=&partnerCode=CFX&partnerSiteLocation=Y&checkReport=DEC&checkReportVersion=30&fid=&test=&cctest=&affiliateId=&subId=&bannerName=&licensePlateNumber=#{plate}&licensePlateState=CA' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-US,en;q=0.8' -H 'Referer: http://www.carfax.com/'`

    if response =~ /year=(\d{4})&amp;make=(\w+)&amp;model=(.+?)&amp;recordCheckType/
    hits << { plate: plate, year: $1, make: $2, model: $3 }
    puts "Found #{hits.last[:plate]} #{hits.last[:year]} #{hits.last[:make]} #{CGI.unescape(HTMLEntities.new.decode hits.last[:model])}"
    end
    end
    end

    puts "Found #{hits.count} plates..."
    puts hits.inspect