| <dependencies> | ||
| <dependency> | ||
| - <groupId>org.jsoup</groupId> | ||
| - <artifactId>jsoup</artifactId> | ||
| - <version>1.9.2</version> | ||
| - </dependency> | ||
| - <dependency> | ||
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| <artifactId>javax.mail</artifactId> | ||
| <version>1.5.5</version> | ||
| + </dependency> | ||
| + <dependency> | ||
| + <groupId>org.joda</groupId> | ||
| + <artifactId>joda-money</artifactId> | ||
| + <version>0.11</version> | ||
| + </dependency> | ||
| + <dependency> | ||
| + <groupId>org.webharvest</groupId> | ||
| + <artifactId>webharvest</artifactId> | ||
| + <version>2.1</version> | ||
| </dependency> | ||
| </dependencies> | ||
| } | ||
| - private T getObject() { | ||
| + protected T getObject() { | ||
| return this.object; | ||
| } |
| package com.whitemagicsoftware.sales; | ||
| +import com.whitemagicsoftware.sales.scraper.Scraper; | ||
| import com.whitemagicsoftware.sales.service.SubscriberService; | ||
| import com.whitemagicsoftware.sales.service.VendorService; | ||
| import com.whitemagicsoftware.sales.service.impl.SubscriberServiceImpl; | ||
| import com.whitemagicsoftware.sales.service.impl.VendorServiceImpl; | ||
| +import java.io.FileNotFoundException; | ||
| +import java.io.InputStream; | ||
| +import java.io.InputStreamReader; | ||
| +import java.io.Reader; | ||
| import java.util.List; | ||
| +import org.webharvest.definition.ScraperConfiguration; | ||
| /** | ||
| } | ||
| - private void run() { | ||
| + private void run() throws FileNotFoundException { | ||
| List<Vendor> vendors = getVendors(); | ||
| List<Subscriber> subscribers = getSubscribers(); | ||
| + | ||
| + ScraperConfiguration config = new ScraperConfiguration( "c:/wh/configs/news.xml" ); | ||
| + Scraper scraper = new Scraper( config, "c:/wh/work/" ); | ||
| + | ||
| +// Jarvest jarvest = new Jarvest(); | ||
| +// | ||
| +// String[] results = jarvest.exec( script( "com_thriftyfoods.rb" ), | ||
| +// "https://www.thriftyfoods.com/product/sunflower-seeds/00000_000000000000005091" ); | ||
| +// | ||
| +// results = jarvest.exec( script( "com_thriftyfoods.rb" ), | ||
| +// "https://www.thriftyfoods.com/product/crisp-applesparkling/00000_000000007468212834" ); | ||
| +// | ||
| +// results = jarvest.exec( script( "com_thriftyfoods.rb" ), | ||
| +// "https://www.thriftyfoods.com/product/four-cheese-manicottipasta/00000_000000005844146203" ); | ||
| + } | ||
| + | ||
| + private Reader script( String resource ) { | ||
| + return new InputStreamReader( getResourceAsStream( resource ) ); | ||
| + } | ||
| + | ||
| + private ClassLoader getContextClassLoader() { | ||
| + return Thread.currentThread().getContextClassLoader(); | ||
| + } | ||
| + private InputStream getResourceAsStream( String resource ) { | ||
| + return getContextClassLoader().getResourceAsStream( resource ); | ||
| } | ||
| package com.whitemagicsoftware.sales; | ||
| +import java.util.Date; | ||
| + | ||
| /** | ||
| - * | ||
| * @author White Magic Software, Ltd. | ||
| */ | ||
| public class Product extends BusinessEntity { | ||
| + private Price sale; | ||
| + private Price regular; | ||
| + | ||
| + private Date expiry; | ||
| protected Product() { | ||
| } | ||
| - public boolean isOnSale() { | ||
| - return false; | ||
| + /** | ||
| + * Answers whether the product is on sale. | ||
| + * | ||
| + * @return true The product is offering its sale price. | ||
| + */ | ||
| + public boolean isSale() { | ||
| + return sale != null; | ||
| } | ||
| - | ||
| } | ||
| */ | ||
| public class Vendor extends BusinessEntity { | ||
| + | ||
| + /** Vendor web site. */ | ||
| + private String webSite; | ||
| public Vendor() { |
| -/* | ||
| - * The MIT License | ||
| - * | ||
| - * Copyright 2016 White Magic Software, Ltd.. | ||
| - * | ||
| - * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| - * of this software and associated documentation files (the "Software"), to deal | ||
| - * in the Software without restriction, including without limitation the rights | ||
| - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| - * copies of the Software, and to permit persons to whom the Software is | ||
| - * furnished to do so, subject to the following conditions: | ||
| - * | ||
| - * The above copyright notice and this permission notice shall be included in | ||
| - * all copies or substantial portions of the Software. | ||
| - * | ||
| - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| - * THE SOFTWARE. | ||
| - */ | ||
| -package com.whitemagicsoftware.sales.scraper; | ||
| - | ||
| -/** | ||
| - * | ||
| - * @author White Magic Software, Ltd. | ||
| - */ | ||
| -public class Scraper { | ||
| - | ||
| -} | ||
| Author | djarvis <email> |
|---|---|
| Date | 2016-06-06 22:02:31 GMT-0700 |
| Commit | a8ffed2eda3b1700693d8eebaa1a5aab4ff2b89d |
| Parent | fa571e6 |
| Delta | 59 lines added, 43 lines removed, 16-line increase |