Ejemplo n.º 1
0
    def parseQuoteVariations(self,divQuoteSummary,dailyQuote):
        #     <div class="yfi_rt_quote_summary_rt_top">
        #        ...
        #            2) the gain/loss amount
        #            <span class="down_r time_rtq_content">
        #                <span ...><img ... alt="Down"><span ... >0.36</span></span>
        #                <span ...><span ...>(2.57%)</span></span> 
        #            </span>
        spanVariation = divQuoteSummary.find("span",class_="time_rtq_content")
            
        # get the sign
        imgVariation = spanVariation.find("img")
        altAttr = imgVariation["alt"]
        
        # get the amount and the percentage
        spanVariationList = spanVariation.find_all("span")
        quoteVar = spanVariationList[0].get_text(strip=True)
        quoteVarPercentage = spanVariationList[1].get_text(strip=True).replace('(','').replace(')','').replace('%','')
        if altAttr == "Down" :
            dailyQuote.isGain = False
        else:
            dailyQuote.isGain = True

        # set the values in the datamodel            
        dailyQuote.variation = StringUtils.stringToCentValue(str(quoteVar))
        dailyQuote.variationPercentage = StringUtils.stringToCentValue(str(quoteVarPercentage))
Ejemplo n.º 2
0
 def parseQuoteAmount(self,divQuoteSummary,dailyQuote):
     #     <div class="yfi_rt_quote_summary_rt_top">
     #        ...
     #            1) the stock quote
     #            <span class="time_rtq_ticker"><span ...>13.64</span></span>
     spanQuote = divQuoteSummary.find("span",class_="time_rtq_ticker")
     quoteAmount = spanQuote.get_text(strip=True)
 
     # set the value in the datamodel            
     dailyQuote.amount = StringUtils.stringToCentValue(str(quoteAmount))