daily_properties 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/daily-properties +6 -0
- data/config/environment.rb +11 -0
- data/lib/daily_properties/cli.rb +50 -0
- data/lib/daily_properties/property.rb +31 -0
- data/lib/daily_properties/scraper.rb +16 -0
- data/lib/daily_properties.rb +6 -0
- metadata +12 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c1fa89cd356c98fad275eb087ecef43d0b942d2
|
4
|
+
data.tar.gz: 426edcd72a65cb1e261a93255c6c710e12531819
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0582d6ebbd7dac099645d374a9c0f1c52f1d869d32459f768857ed775a68e2061bafa97b74e7e7d287b7ad0551527f42ac857542c7f94d6b01d3562ab5082d3
|
7
|
+
data.tar.gz: 68422c2646b73569cf604ee198f91e342a9d1d6170e0cebdd9b2a7319d3166aed3868d4100b2179633e8ebedff4c6aeb50624caf4c3328624f6d38a188c24dd0
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
require 'open-uri'
|
3
|
+
require 'bundler'
|
4
|
+
Bundler.require
|
5
|
+
|
6
|
+
require_relative "../lib/daily_properties/version"
|
7
|
+
require_relative '../lib/daily_properties/cli'
|
8
|
+
require_relative '../lib/daily_properties/scraper'
|
9
|
+
require_relative '../lib/daily_properties/property'
|
10
|
+
|
11
|
+
# serves as a config/environment file that requires the rest of the files and is required by the main console file
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# CLI Controller
|
2
|
+
|
3
|
+
class DailyProperties::CLI
|
4
|
+
def call
|
5
|
+
puts "Welcome! Please enter the zipcode, and I will list the 26 most recently sold properties in that area:"
|
6
|
+
zipcode = gets.strip.to_i
|
7
|
+
list_properties(zipcode)
|
8
|
+
menu
|
9
|
+
end
|
10
|
+
|
11
|
+
def list_properties(zipcode)
|
12
|
+
DailyProperties::Scraper.make_properties(zipcode)
|
13
|
+
@properties = DailyProperties::Property.property
|
14
|
+
@properties.each.with_index(1) do |property, i|
|
15
|
+
puts "#{i}. #{property.address}, #{property.sold_date} at #{property.price}"
|
16
|
+
end
|
17
|
+
puts "--------------------------------------------------"
|
18
|
+
end
|
19
|
+
|
20
|
+
def menu
|
21
|
+
input = nil
|
22
|
+
while input != "exit"
|
23
|
+
puts "Enter the number of the property that you'd like to know more about, or enter another to look up another zipcode, or enter list to see the list, or enter exit: "
|
24
|
+
input = gets.strip.downcase
|
25
|
+
if input.to_i > 0 && input.to_i < 27
|
26
|
+
the_property = @properties[input.to_i - 1]
|
27
|
+
puts "#{the_property.address}, #{the_property.sold_date} at #{the_property.price}"
|
28
|
+
puts "See more at #{the_property.url}"
|
29
|
+
elsif input == "another"
|
30
|
+
DailyProperties::Property.clear_all
|
31
|
+
puts "--------------------------------------------------"
|
32
|
+
call
|
33
|
+
elsif input == "list"
|
34
|
+
list_properties
|
35
|
+
elsif input == "exit"
|
36
|
+
goodbye
|
37
|
+
exit
|
38
|
+
else
|
39
|
+
puts "Not sure what you just enter. Type list or exit. "
|
40
|
+
puts "--------------------------------------------------"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def goodbye
|
46
|
+
puts "Thanks for trying me out. See you soon!"
|
47
|
+
puts "--------------------------------------------------"
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class DailyProperties::Property
|
2
|
+
attr_accessor :address, :price, :sold_date, :url
|
3
|
+
@@all = []
|
4
|
+
|
5
|
+
def initialize(address = nil, price = nil, sold_date = nil, url = nil)
|
6
|
+
@address = address
|
7
|
+
@price = price
|
8
|
+
@sold_date = sold_date
|
9
|
+
@url = url
|
10
|
+
@@all << self unless @@all.detect{|p| p.address == address}
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.new_from_page(property)
|
14
|
+
self.new(
|
15
|
+
property.css(".zsg-photo-card-address").text,
|
16
|
+
property.css("span.zsg-photo-card-status").text,
|
17
|
+
property.css(".zsg-photo-card-notification").text,
|
18
|
+
'http://www.zillow.com' + property.css("a").attr("href")
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.property
|
23
|
+
@@all
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.clear_all
|
27
|
+
@@all.clear
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class DailyProperties::Scraper
|
2
|
+
|
3
|
+
def self.get_page(zipcode)
|
4
|
+
index_url = "https://www.zillow.com/homes/recently_sold/#{zipcode}/"
|
5
|
+
doc = Nokogiri::HTML(open(index_url))
|
6
|
+
doc.css(".zsg-photo-card-content")
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.make_properties(zipcode)
|
10
|
+
self.get_page(zipcode).each do |property|
|
11
|
+
DailyProperties::Property.new_from_page(property)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daily_properties
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jingru Zhang
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: nokogiri
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,16 +66,21 @@ dependencies:
|
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '1.7'
|
83
|
-
description:
|
84
|
-
This CLI gem helps home buyers and sellers to view the most recently sold properties within a given zipcode. Use 'daily-properties' command to run.
|
85
|
-
It asks users for a zipcode input, and gives users a list of 26 most recently sold properties. Users can type respective property number to get the url to view more details of the property.
|
69
|
+
description:
|
86
70
|
email:
|
87
71
|
- zhang.jingru.93@gmail.com
|
88
|
-
executables:
|
72
|
+
executables:
|
73
|
+
- daily-properties
|
89
74
|
extensions: []
|
90
75
|
extra_rdoc_files: []
|
91
|
-
files:
|
92
|
-
|
76
|
+
files:
|
77
|
+
- bin/daily-properties
|
78
|
+
- config/environment.rb
|
79
|
+
- lib/daily_properties.rb
|
80
|
+
- lib/daily_properties/cli.rb
|
81
|
+
- lib/daily_properties/property.rb
|
82
|
+
- lib/daily_properties/scraper.rb
|
83
|
+
homepage: https://github.com/jingruzhang/cli_daily_properties.git
|
93
84
|
licenses:
|
94
85
|
- MIT
|
95
86
|
metadata: {}
|