commit 48904447369f47013ac23250bf6a157a6ec1e873
parent d8e40ca538435ee63cd5fd3b2ebadb1d666cf674
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Sun, 12 Oct 2014 22:20:28 -0600
product_scraper: add support for text brands
Diffstat:
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/product_scraper.pl b/product_scraper.pl
@@ -88,9 +88,13 @@ for (keys %product_map) {
 		my $title = $product->find(".ProductTitle")->text();
 		next if (not_defined($title, "title", $node));
 
-		# brand is easier to parse from general results page
-		my $brand = $product->find(".ProductBrand")->html();
-		($brand) = ($brand =~ m/Brand: ([A-Za-z]+)/);
+		# brand is easier to parse from general results page, sometimes
+		# shows up as text
+		my $brand = $product->find(".ProductBrand")->text();
+		if ($brand eq "") {
+			my $brand = $product->find(".ProductBrand")->html();
+			($brand) = ($brand =~ m/Brand: ([A-Za-z]+)/);
+		}
 		next if (not_defined($brand, "brand", $node));
 
 		# used to visit the actual product page