class SteamCartItem(demiurge.Item): appid = demiurge.AttributeValueField(attr='data-ds-appid', selector='div.cart_row') packageid = demiurge.AttributeValueField(attr='data-ds-packageid', selector='div.cart_row') title = demiurge.TextField(selector='div.cart_item_desc a:first') price = demiurge.TextField(selector='div.cart_item_price div.price:last') remove_button = demiurge.AttributeValueField(attr='href', selector='a.remove_link') class Meta: selector = 'div.cart_row'
class Products(demiurge.Item): title = demiurge.TextField(selector='span.product-info-title') price = demiurge.TextField(selector='span.product-info-price') url = demiurge.AttributeValueField(selector='div.card-product a:eq(0)', attr='href') image_url = demiurge.AttributeValueField(selector='img.card-product-image', attr='src') class Meta: selector = 'div.card-product'
class GoogleShoppingItem (demiurge.Item): #url = demiurge.AttributeValueField (selector='td:eq(2) a:eq(1)', attr='href') #name = demiurge.TextField(selector='td:eq(2) a:eq(2)') #size = demiurge.TextField(selector='td:eq(3)') heading = demiurge.TextField(selector='.pslires h3') #'.pslmain h3') image = demiurge.AttributeValueField (selector='.pslires .psliimg img', attr='alt') link = demiurge.AttributeValueField (selector='.pslires h3 a', attr='href') price = demiurge.TextField(selector='.pslires div b:contains("$")') #'.pslline price') # best price, usually 30-40% lower than avg rows = demiurge.RelatedItem (ItemPriceDetailRow, selector=".pslires h3 a", attr="href") #main = demiurge.TextField(selector='.pslmain') class Meta: #selector = '.pslicont' #'table.maintable:gt(0) tr:gt(0)' selector = '.pslires' #'table.maintable:gt(0) tr:gt(0)' base_url = 'https://www.google.com' #'http://www.mininova.org'
class TestItem(demiurge.Item): label = demiurge.TextField(selector='.link') url = demiurge.AttributeValueField(selector='.link', attr='href') class Meta: base_url = 'http://localhost' selector = "p.p_with_link" extra_attribute = 'value'
class SteamGift(demiurge.Item): gift_javascript = demiurge.TextField( selector='div:last-child div.pending_gift_leftcol script') from_link = demiurge.AttributeValueField( selector='div:last-child div.pending_gift_rightcol p:first-child a', attr='href') from_username = demiurge.TextField( selector='div:last-child div.pending_gift_rightcol p:first-child a') accept_button = demiurge.AttributeValueField( selector= 'div:last-child div.pending_gift_rightcol div.gift_controls div.gift_controls_buttons div.btn_medium:first', attr='onclick') class Meta: selector = 'div.pending_gift'
class SteamCart(demiurge.Item): count = demiurge.TextField(selector='span#cart_item_count_value') subtotal = demiurge.TextField(selector='div#cart_price_total') balance = demiurge.TextField(selector='a#header_wallet_balance') cart_status_message = demiurge.TextField(selector='div.cart_status_message') cart_checkout_button = demiurge.AttributeValueField(selector='a.continue:eq(0)', attr='href') items = demiurge.RelatedItem(SteamCartItem, selector='div.cart_item_list')
class ItemPriceDetailRow (demiurge.Item): #url = demiurge.AttributeValueField (selector='.pslires .psliimg img', attr='href') seller = demiurge.TextField (selector="td.os-seller-name") rating = demiurge.AttributeValueField (selector="td.os-rating-col span div[aria-label]", attr="aria-label" ) votes = demiurge.TextField (selector="td.os-rating-col a") details = demiurge.TextField (selector="td.os-details-col") price = demiurge.TextField (selector="td.os-price-col span.os-base_price") total = demiurge.TextField (selector="td.os-total-col") class Meta: selector = 'tr.os-row'
class GoogleShoppingItem(demiurge.Item): #url = demiurge.AttributeValueField (selector='td:eq(2) a:eq(1)', attr='href') #name = demiurge.TextField(selector='td:eq(2) a:eq(2)') #size = demiurge.TextField(selector='td:eq(3)') heading = demiurge.TextField(selector='.pslmain h3') image = demiurge.AttributeValueField(selector='.pslimg img', attr='alt') price = demiurge.TextField(selector='.pslline price') main = demiurge.TextField(selector='.pslmain') class Meta: selector = '.pslicont' #'table.maintable:gt(0) tr:gt(0)' base_url = 'https://www.google.com' #'http://www.mininova.org'
class TestItemWithFieldCoercion(demiurge.Item): label = demiurge.TextField(selector='a.page', coerce=int) url = demiurge.AttributeValueField(selector='a.page', attr='href', coerce=bool) def clean_label(self, value): # remove the Page prefix return value[5:] class Meta: base_url = 'http://localhost' selector = 'div.pagination'
class Round(demiurge.Item): _css_class = demiurge.AttributeValueField(attr='class') title = demiurge.TextField(selector='div.subHeader') matches = demiurge.RelatedItem(Match) class Meta: selector = 'div.fase div.fecha' encoding = 'utf-8' base_url = BASE_URL + 'fixture.html' @property def is_current(self): return 'show' in self._css_class
class ExternalForm(demiurge.Item): link = demiurge.AttributeValueField(selector='form#externalForm', attr='action')