Exemplo n.º 1
0
            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
Exemplo n.º 2
0
            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)
Exemplo n.º 3
0
            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
Exemplo n.º 4
0
            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
Exemplo n.º 5
0
            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
Exemplo n.º 6
0
            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
Exemplo n.º 7
0
 def obj_label(self):
     tablecell = TableCell('label')(self)[0]
     label = tablecell.xpath('./div[position()=1]')
     return CleanText(label)(self)
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
 def obj_quantity(self):
     tablecell = TableCell('quantity', colspan=True)(self)[0]
     return CleanDecimal(tablecell.xpath('./span'), replace_dots=True)(self)
Exemplo n.º 10
0
 def obj_url(self):
     td = TableCell('id')(self)[0]
     return Link(td.xpath('./a'))(self)
Exemplo n.º 11
0
 def obj_quantity(self):
     tablecell = TableCell('quantity', colspan=True)(self)[0]
     return CleanDecimal(tablecell.xpath('./span'), replace_dots=True)(self)
Exemplo n.º 12
0
 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)
Exemplo n.º 13
0
 def obj_id(self):
     tablecell = TableCell('id')(self)[0]
     id = tablecell.xpath('./div[position()=2]')
     return CleanText().filter(id)
Exemplo n.º 14
0
 def obj_id(self):
     tablecell = TableCell('id')(self)[0]
     _id = tablecell.xpath('./div[position()=2]')
     return CleanText(_id)(self)
Exemplo n.º 15
0
 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)
Exemplo n.º 16
0
 def obj_label(self):
     tablecell = TableCell('label')(self)[0]
     return CleanText(
         tablecell.xpath('./following-sibling::td[@class=""]/div/a')
         [0])(self)
Exemplo n.º 17
0
 def obj_quantity(self):
     tablecell = TableCell('quantity')(self)[0]
     return CleanDecimal.French(tablecell.xpath('./span'))(self)
Exemplo n.º 18
0
 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
Exemplo n.º 19
0
 def obj_label(self):
     tablecell = TableCell('label')(self)[0]
     label = tablecell.xpath('./div[position()=1]')
     return CleanText(label)(self)
Exemplo n.º 20
0
 def obj_balance(self):
     tablecell = TableCell('balance')(self)[0]
     balance = tablecell.xpath('./span[@class="intraday"]')
     return CleanDecimal.French(balance)(self)
Exemplo n.º 21
0
 def obj_currency(self):
     tablecell = TableCell('balance')(self)[0]
     currency = tablecell.xpath('./span[@class="intraday"]')
     return Currency(currency)(self)
Exemplo n.º 22
0
 def obj_url(self):
     td = TableCell('id')(self)[0]
     return Link(td.xpath('./a'))(self)