summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2017-05-04 23:11:06 (GMT)
committerWerner Almesberger <werner@almesberger.net>2017-05-04 23:11:06 (GMT)
commite82617f5a9cae54c9984b2ee19e81e4d32527e08 (patch)
tree6f040ee7cbbc423a76efdafde186de251b0f0aa5
parent9d3d6533b1e54d783a8fb70bd201ffbe72ae601e (diff)
downloadmisc-e82617f5a9cae54c9984b2ee19e81e4d32527e08.zip
misc-e82617f5a9cae54c9984b2ee19e81e4d32527e08.tar.gz
misc-e82617f5a9cae54c9984b2ee19e81e4d32527e08.tar.bz2
bom/newark2pricing.pl: update for new page syntax
-rwxr-xr-xbom/newark2pricing.pl34
1 files changed, 19 insertions, 15 deletions
diff --git a/bom/newark2pricing.pl b/bom/newark2pricing.pl
index b2fd7bb..98e1ac5 100755
--- a/bom/newark2pricing.pl
+++ b/bom/newark2pricing.pl
@@ -2,8 +2,8 @@
#
# bom/newark2pricing.pl - Obtain stock and pricing for Newark parts
#
-# Written 2014, 2016 by Werner Almesberger
-# Copyright 2014, 2016 by Werner Almesberger
+# Written 2014, 2016-2017 by Werner Almesberger
+# Copyright 2014, 2016-2017 by Werner Almesberger
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -15,7 +15,8 @@ require "cache.pl";
$TAG = "NEWARK";
-$URL_BASE = "http://www.newark.com/webapp/wcs/stores/servlet/Search?st=";
+#$URL_BASE = "http://www.newark.com/webapp/wcs/stores/servlet/Search?st=";
+$URL_BASE = "http://www.newark.com/search?st=";
sub retrieve
@@ -35,9 +36,9 @@ sub lookup
local ($page) = @_;
local $t, $p;
- my $qty = '>Availability:<[^<]*?((\d+,)*\d+)';
- my $price = '<h3>Price(.*?)</table';
- my $entry = '(\d+)(&nbsp;-&nbsp;\d+|\+).*?\$(\d+\.\d+)';
+ my $qty = 'class="availability".*?>[^<]*?((\d+,)*\d+)';
+ my $price = 'class="tableProductDetailPrice.*?>(.*?)</table';
+ my $entry = '(\d+)(&nbsp;-&nbsp;\d+|\s*\+).*?\$(\d+\.\d+)';
my @p = undef;
@@ -48,17 +49,20 @@ sub lookup
push(@p, 0);
}
- die unless $page =~ /$price/s;
- $p = $1;
+ if ($page =~ /$price/s) {
+ $p = $1;
- while ($p =~ /$entry/s) {
- local ($b, $u) = ($1, $3);
+ while ($p =~ /$entry/s) {
+ local ($b, $u) = ($1, $3);
+
+ $b =~ tr/,//d;
+ $u =~ tr/,//d;
- $b =~ tr/,//d;
- $u =~ tr/,//d;
-
- push(@p, $b, $u);
- $p = $';
+ push(@p, $b, $u);
+ $p = $';
+ }
+ } else {
+ die unless $page =~ /Pricing is unavailable/;
}
my $d = "";