<?xml version="1.0" encoding="UTF-8"?> <config charset="UTF-8"> <var-def name="vendor_url">http://specials.safeway.ca/flyers/accessibility/safewaycanada-flyer</var-def> <var-def name="vendor_name">Safeway</var-def> <var-def name="product_text">description</var-def> <!-- 1. Find store code for nearest store. 2. Download flyer for store code. 3. Search for matching product name(s). TODO: Save and re-use the flyer for a particular store code per week. --> <var-def name="store_code"> <xpath expression="(//select[@id='store_select']/option/@value)[1]"> <html-to-xml> <http method="get" url="${vendor_url}"> <http-param name="type">1</http-param> <http-param name="postal_code"> <var name="location_code"/> </http-param> </http> </html-to-xml> </xpath> </var-def> <var-def name="flyer_page"> <html-to-text> <html-to-xml htmlparser="jsoup"> <http method="get" url="${vendor_url}"> <http-param name="store_code"> <var name="store_code"/> </http-param> </http> </html-to-xml> </html-to-text> </var-def> <!-- Replace spaces with .* to match product text with split phrases. For example, "red grapes" should match "red or green grapes". --> <var-def name="product_regex"> <regexp replace="true"> <regexp-pattern>[\s]</regexp-pattern> <regexp-source> <var name="product_name" /> </regexp-source> <regexp-result> <template>.*</template> </regexp-result> </regexp> </var-def> <var-def name="product_price"> <regexp flag-caseinsensitive="yes" flag-dotall="no"> <regexp-pattern>.*<var name="product_regex"/>.*</regexp-pattern> <regexp-source> <var name="flyer_page" /> </regexp-source> </regexp> </var-def> <!-- See postfix.xml --> </config>