Class: Scraper
- Inherits:
-
Object
- Object
- Scraper
- Defined in:
- lib/FreeWiFiNYC/scraper.rb
Overview
require ‘./cli’ require ‘./FreeWiFiNYC’
Instance Attribute Summary collapse
-
#all_nyc_zips ⇒ Object
Returns the value of attribute all_nyc_zips.
-
#borough ⇒ Object
Returns the value of attribute borough.
-
#data ⇒ Object
Returns the value of attribute data.
-
#find_wifi_input ⇒ Object
Returns the value of attribute find_wifi_input.
-
#zip_codes ⇒ Object
Returns the value of attribute zip_codes.
Class Method Summary collapse
- .all_data ⇒ Object
- .backup_nyc_zips ⇒ Object
- .scrape_data ⇒ Object
-
.zips ⇒ Object
def self.zipcode_hardcode codes = [10001, 10002, 10003, 10004, 10005, 10006, 10007, 10009, 10010, 10011, 10012, 10013, 10014, 10016, 10017, 10018, 10019, 10020, 10021, 10022, 10023, 10024, 10025, 10026, 10027, 10028, 10029, 10030, 10031, 10032, 10033, 10034, 10035, 10036, 10037, 10038, 10039, 10040, 10044, 10065, 10069, 10075, 10103, 10110, 10111, 10112, 10115, 10119, 10128, 10152, 10153, 10154, 10162, 10165, 10167, 10168, 10169, 10170, 10171, 10172, 10173, 10174, 10177, 10199, 10271, 10278, 10279, 10280, 10282, 10301, 10302, 10303, 10304, 10305, 10306, 10307, 10308, 10309, 10310, 10311, 10312, 10314, 10451, 10452, 10453, 10454, 10455, 10456, 10457, 10458, 10459, 10460, 10461, 10462, 10463, 10464, 10465, 10466, 10467, 10468, 10469, 10470, 10471, 10472, 10473, 10474, 10475, 11001, 11003, 11004, 11005, 11040, 11101, 11102, 11103, 11104, 11105, 11106, 11109, 11201, 11203, 11204, 11205, 11206, 11207, 11208, 11209, 11210, 11211, 11212, 11213, 11214, 11215, 11216, 11217, 11218, 11219, 11220, 11221, 11222, 11223, 11224, 11225, 11226, 11228, 11229, 11230, 11231, 11232, 11233, 11234, 11235, 11236, 11237, 11238, 11239, 11351, 11354, 11355, 11356, 11357, 11358, 11359, 11360, 11361, 11362, 11363, 11364, 11365, 11366, 11367, 11368, 11369, 11370, 11371, 11372, 11373, 11374, 11375, 11377, 11378, 11379, 11385, 11411, 11412, 11413, 11414, 11415, 11416, 11417, 11418, 11419, 11420, 11421, 11422, 11423, 11424, 11425, 11426, 11427, 11428, 11429, 11430, 11432, 11433, 11434, 11435, 11436, 11451, 11691, 11692, 11693, 11694, 11697] end.
Instance Method Summary collapse
Instance Attribute Details
#all_nyc_zips ⇒ Object
Returns the value of attribute all_nyc_zips.
6 7 8 |
# File 'lib/FreeWiFiNYC/scraper.rb', line 6 def all_nyc_zips @all_nyc_zips end |
#borough ⇒ Object
Returns the value of attribute borough.
6 7 8 |
# File 'lib/FreeWiFiNYC/scraper.rb', line 6 def borough @borough end |
#data ⇒ Object
Returns the value of attribute data.
6 7 8 |
# File 'lib/FreeWiFiNYC/scraper.rb', line 6 def data @data end |
#find_wifi_input ⇒ Object
Returns the value of attribute find_wifi_input.
6 7 8 |
# File 'lib/FreeWiFiNYC/scraper.rb', line 6 def find_wifi_input @find_wifi_input end |
#zip_codes ⇒ Object
Returns the value of attribute zip_codes.
6 7 8 |
# File 'lib/FreeWiFiNYC/scraper.rb', line 6 def zip_codes @zip_codes end |
Class Method Details
.all_data ⇒ Object
63 64 65 |
# File 'lib/FreeWiFiNYC/scraper.rb', line 63 def self.all_data @data end |
.backup_nyc_zips ⇒ Object
59 60 61 |
# File 'lib/FreeWiFiNYC/scraper.rb', line 59 def self.backup_nyc_zips @all_nyc_zips.sort.uniq end |
.scrape_data ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/FreeWiFiNYC/scraper.rb', line 12 def self.scrape_data @all_nyc_zips = [] @zip_codes = [] parsed_data = Nokogiri::HTML(open("https://data.cityofnewyork.us/resource/yjub-udmw.json?$offset=0&$limit=5000")) zips_nyc_data = Nokogiri::HTML(open("http://www.city-data.com/zipmaps/New-York-New-York.html")) backup_zips = Nokogiri::HTML(open("https://www.health.ny.gov/statistics/cancer/registry/appendix/neighborhoods.htm")) @data = JSON.parse(parsed_data) @all_nyc_zips = zips_nyc_data.css("div.zip-codes a").text.scan(/\d{5}/) @backup_nyc_zips = parsed_data.css("td").text.scan(/\d+/) zips end |
.zips ⇒ Object
def self.zipcode_hardcode
codes = [10001, 10002, 10003, 10004, 10005, 10006, 10007, 10009,
10010, 10011, 10012, 10013, 10014, 10016, 10017, 10018, 10019, 10020,
10021, 10022, 10023, 10024, 10025, 10026, 10027, 10028, 10029, 10030,
10031, 10032, 10033, 10034, 10035, 10036, 10037, 10038, 10039, 10040,
10044, 10065, 10069, 10075, 10103, 10110, 10111, 10112, 10115, 10119,
10128, 10152, 10153, 10154, 10162, 10165, 10167, 10168, 10169, 10170,
10171, 10172, 10173, 10174, 10177, 10199, 10271, 10278, 10279, 10280,
10282, 10301, 10302, 10303, 10304, 10305, 10306, 10307, 10308, 10309,
10310, 10311, 10312, 10314, 10451, 10452, 10453, 10454, 10455, 10456,
10457, 10458, 10459, 10460, 10461, 10462, 10463, 10464, 10465, 10466,
10467, 10468, 10469, 10470, 10471, 10472, 10473, 10474, 10475, 11001,
11003, 11004, 11005, 11040, 11101, 11102, 11103, 11104, 11105, 11106,
11109, 11201, 11203, 11204, 11205, 11206, 11207, 11208, 11209, 11210,
11211, 11212, 11213, 11214, 11215, 11216, 11217, 11218, 11219, 11220,
11221, 11222, 11223, 11224, 11225, 11226, 11228, 11229, 11230, 11231,
11232, 11233, 11234, 11235, 11236, 11237, 11238, 11239, 11351, 11354,
11355, 11356, 11357, 11358, 11359, 11360, 11361, 11362, 11363, 11364,
11365, 11366, 11367, 11368, 11369, 11370, 11371, 11372, 11373, 11374,
11375, 11377, 11378, 11379, 11385, 11411, 11412, 11413, 11414, 11415,
11416, 11417, 11418, 11419, 11420, 11421, 11422, 11423, 11424, 11425,
11426, 11427, 11428, 11429, 11430, 11432, 11433, 11434, 11435, 11436,
11451, 11691, 11692, 11693, 11694, 11697]
end
52 53 54 55 56 57 |
# File 'lib/FreeWiFiNYC/scraper.rb', line 52 def self.zips Scraper.all_data.each do |each_entry| @zip_codes << each_entry["zip"] unless @zip_codes.include?(each_entry["zip"]) end @zip_codes.sort end |
Instance Method Details
#test ⇒ Object
8 9 10 |
# File 'lib/FreeWiFiNYC/scraper.rb', line 8 def test puts "Scraper Test" end |