amazon_wish_miner 0.2.0 → 0.3.0
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/lib/amazon_wish_miner/amazon_wish.rb +10 -0
- data/lib/amazon_wish_miner/amazon_wish_list.rb +13 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 540e25cc6d5661cf2c65b24a2827cfa670caa455c845c1a039cfe94ef44c536f
|
4
|
+
data.tar.gz: f2f7d46b8eca7e5d088416757f842edf5d6ebc078e374dd8477bf17d5d48a303
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c73aaca8ec8b6a58ed3ad6ab808d0e163345beed25d571b7e782197d198bbf22b9a6b126ede29a42a6eae7a5e596b848ca580e1cbfc8c1eaf84cc0a72a2a3dc
|
7
|
+
data.tar.gz: 24d4a0577dea49247f4fc1569321b5f254d280c12024de29a400acbb7920657fecfc8a161aa52ec3acd023d83dd961c9c8f32e96a5dad4ee6502fdea7b61e7c1
|
@@ -80,4 +80,14 @@ class AmazonWish
|
|
80
80
|
chars.drop_while(&TITLE_TRIMMER).reverse.drop_while(&TITLE_TRIMMER).reverse.join
|
81
81
|
end
|
82
82
|
|
83
|
+
def self.attributes_from_responses(page_responses)
|
84
|
+
page_responses.each_with_object(Array.new) do |pr, item_attrs|
|
85
|
+
Nokogiri::HTML(pr).css('ul#g-items li').each do |li|
|
86
|
+
aln = li.css('.a-link-normal')
|
87
|
+
attrs_hash = { title: aln.attribute('title').value, href: aln.attribute('href').value }
|
88
|
+
item_attrs << attrs_hash
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
83
93
|
end
|
@@ -12,6 +12,19 @@ class AmazonWishList
|
|
12
12
|
@wishes = wishes
|
13
13
|
end
|
14
14
|
|
15
|
+
# the method below only sends one request, so it less likely to be identified as being used by a scraper
|
16
|
+
def self.wishlist_attributes(amazon_list_id, reveal = :all, sort = :date_added, tld = 'com')
|
17
|
+
raise "invalid reveal" unless REVEAL_OPTIONS.include?(reveal)
|
18
|
+
raise "invalid sort" unless SORT_OPTIONS[sort]
|
19
|
+
|
20
|
+
query_params = {reveal: reveal.to_s, sort_string: SORT_OPTIONS[sort]}
|
21
|
+
# lek is nil for the first page
|
22
|
+
url_without_qstring = "http://www.amazon.#{tld}/hz/wishlist/ls/#{amazon_list_id}"
|
23
|
+
|
24
|
+
pages = self.get_all_wishlist_pages(url_without_qstring, query_params)
|
25
|
+
AmazonWish.attributes_from_responses(pages)
|
26
|
+
end
|
27
|
+
|
15
28
|
# TODO: https://www.amazon.com/hz/wishlist/ls/2WHUDN1UIDVUT/ref=cm_sw_r_cp_ep_ws_8xNVBb731TTMS,
|
16
29
|
#=> https://www.amazon.com/gp/registry/wishlist/2WHUDN1UIDVUT/ref=cm_sw_r_cp_ep_ws_8xNVBb731TTMS,
|
17
30
|
#=> and https://www.amazon.com/registry/wishlist/2WHUDN1UIDVUT/ref=cm_sw_r_cp_ep_ws_8xNVBb731TTMS
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon_wish_miner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander V. Trujillo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.8'
|
41
|
-
description:
|
41
|
+
description: Loosely modeled after Amazon Wish Lister http://doitlikejustin.github.io/amazon-wish-lister/
|
42
42
|
email:
|
43
43
|
executables: []
|
44
44
|
extensions: []
|