pricecharts

track prices of consumer electronics
Log | Files | Refs | README

commit 38b01c17db70af16c70b9b75000b302494d3c18f
parent 60346754980b30e22c556d2b580674f3e29e2b5d
Author: kyle <kyle@getaddrinfo.net>
Date:   Sun,  6 Mar 2016 10:57:37 -0700

memexp: add product page description scraping support.

Diffstat:
MPS/MemoryExpress.pm | 6++++++
Mt/memory_express.t | 5++++-
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/PS/MemoryExpress.pm b/PS/MemoryExpress.pm @@ -91,6 +91,12 @@ sub scrape_price { } sub scrape_description { + my ($self, $resp) = @_; + my $dom = HTML::Grabber->new( html => $resp->decoded_content ); + + # Product page description is inside <h1> tags + my $description = $dom->find(".PDH_HeaderBlock h1")->text(); + return $description; } sub find_product_page { diff --git a/t/memory_express.t b/t/memory_express.t @@ -4,7 +4,7 @@ use PS::MemoryExpress; use Log::Log4perl qw(:easy); use Test; -BEGIN { plan tests => 17 } +BEGIN { plan tests => 18 } Log::Log4perl->easy_init($INFO); @@ -36,6 +36,9 @@ ok(@others == 0); ok($price > 200.0); ok($price < 400.0); +my $descr = $me->scrape_description($resp); +ok($descr, "8TB Archive HDD, SATA III w/ 128MB Cache"); + # Search for something I know has multiple results #