def obj_currency(self): tablecell = TableCell('balance')(self)[0] text = tablecell.xpath('./span/text()')[0] regex = '[0-9,.]* (.*)' currency = Currency().filter(re.search(regex, text).group(1)) return currency
def original_unitvalue(self): tablecell = TableCell('unitvalue', colspan=True)(self)[0] text = tablecell.xpath('./text()')[0] regex = '[0-9,]* (.*)' currency = Currency().filter(re.search(regex, text).group(1)) return currency, CleanDecimal(replace_dots=True).filter(text)
def obj_code(self): # We try to get the code from <a> div. If we didn't find code in url, # we try to find it in the cell text tablecell = TableCell('label', colspan=True)(self)[0] # url find try url = tablecell.xpath('./following-sibling::td[position()=1]/div/a')[0].attrib['href'] code_match = re.search(r'sico=([A-Z0-9]*)', url) if code_match: if is_isin_valid(code_match.group(1)): return code_match.group(1) # cell text find try text = CleanText(tablecell.xpath('./following-sibling::td[position()=1]/div')[0])(self) for code in text.split(' '): if is_isin_valid(code): return code return NotAvailable
def obj_code(self): # We try to get the code from <a> div. If we didn't find code in url, # we try to find it in the cell text tablecell = TableCell('label', colspan=True)(self)[0] # url find try code_match = Regexp( Link(tablecell.xpath('./following-sibling::td[position()=1]/div/a')), r'sico=([A-Z0-9]*)', default=None)(self) if is_isin_valid(code_match): return code_match # cell text find try text = CleanText(tablecell.xpath('./following-sibling::td[position()=1]/div')[0])(self) for code in text.split(' '): if is_isin_valid(code): return code return NotAvailable
def obj_vdate(self): tablecell = TableCell('vdate', colspan=True)(self)[0] vdate_scrapped = tablecell.xpath('./preceding-sibling::td[position()=1]//span/text()')[0] # Scrapped date could be a schedule time (00:00) or a date (01/01/1970) vdate = NotAvailable if ':' in vdate_scrapped: today = datetime.date.today() h, m = [int(x) for x in vdate_scrapped.split(':')] hour = datetime.time(hour=h, minute=m) vdate = datetime.datetime.combine(today, hour) elif '/' in vdate_scrapped: vdate = datetime.datetime.strptime(vdate_scrapped, '%d/%m/%y') return vdate
def obj_label(self): tablecell = TableCell('label')(self)[0] label = tablecell.xpath('./div[position()=1]') return CleanText(label)(self)
def obj_label(self): tablecell = TableCell('label', colspan=True)(self)[0] label = CleanText(tablecell.xpath('./following-sibling::td[@class=""]/div/a')[0])(self) return label
def obj_quantity(self): tablecell = TableCell('quantity', colspan=True)(self)[0] return CleanDecimal(tablecell.xpath('./span'), replace_dots=True)(self)
def obj_url(self): td = TableCell('id')(self)[0] return Link(td.xpath('./a'))(self)
def obj_balance(self): tablecell = TableCell('balance')(self)[0] b = tablecell.xpath('./span[@class="intraday"]') balance = CleanDecimal(replace_dots=True).filter(b) return Decimal(balance)
def obj_id(self): tablecell = TableCell('id')(self)[0] id = tablecell.xpath('./div[position()=2]') return CleanText().filter(id)
def obj_id(self): tablecell = TableCell('id')(self)[0] _id = tablecell.xpath('./div[position()=2]') return CleanText(_id)(self)
def original_unitvalue(self): tablecell = TableCell('unitvalue')(self)[0] text = tablecell.xpath('./text()') return Currency( text, default=NotAvailable)(self), CleanDecimal.French( text, default=NotAvailable)(self)
def obj_label(self): tablecell = TableCell('label')(self)[0] return CleanText( tablecell.xpath('./following-sibling::td[@class=""]/div/a') [0])(self)
def obj_quantity(self): tablecell = TableCell('quantity')(self)[0] return CleanDecimal.French(tablecell.xpath('./span'))(self)
def obj_balance(self): tablecell = TableCell('balance')(self)[0] balance = tablecell.xpath('./span[@class="intraday"]') return CleanDecimal.French(balance)(self)
def obj_currency(self): tablecell = TableCell('balance')(self)[0] currency = tablecell.xpath('./span[@class="intraday"]') return Currency(currency)(self)