当前位置: 首页>>代码示例>>Python>>正文


Python OrangeGbl.dbAssetReview方法代码示例

本文整理汇总了Python中OrangeGbl.dbAssetReview方法的典型用法代码示例。如果您正苦于以下问题:Python OrangeGbl.dbAssetReview方法的具体用法?Python OrangeGbl.dbAssetReview怎么用?Python OrangeGbl.dbAssetReview使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OrangeGbl的用法示例。


在下文中一共展示了OrangeGbl.dbAssetReview方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ParseQristoranti

# 需要导入模块: import OrangeGbl [as 别名]
# 或者: from OrangeGbl import dbAssetReview [as 别名]

#.........这里部分代码省略.........
        if LastReviewDate is not None and LastReviewDate != '':            
            # aggiorno la data di ultima recensione sulla tabella asset del source
            rc = gL.dbLastReviewDate(Asset, LastReviewDate)
        
        AddrWebsite = ''
        AddrCounty  = ''
        AddrStreet  = ''
        AddrZIP     = ''
        AddrPhone   = ''      
        AddrPhone1  = ''      
        AddrCity    = ''               
        AddrWebsite = content.xpath('//td[contains(.,"sito")]//@href') # link al sito
        if len(AddrWebsite)>0:
            AddrWebsite = AddrWebsite[0]
        ind = content.xpath('//td[contains(., "Indirizzo")]/following-sibling::td/text()')
        if len(ind) > 0:
            a = ind[0].split(",")
            AddrStreet = gL.StdCar(a[0])
            AddrZIP = AddrCounty = AddrCity = ""
                   
        test = content.xpath('//td[contains(., "Telefono")]/following-sibling::td/text()')
        if len(test) > 0:
            AddrPhone = test[0]
        else:
            AddrPhone = ''
        #AddrPhone = gL.StdPhone(AddrPhone, country)
        AddrPhone, AddrPhone1 = gL.StdPhone(AddrPhone, country)

        AddrList = {'AddrStreet': AddrStreet,
                    'AddrCity': AddrCity,
                    'AddrCounty': AddrCounty,
                    'AddrZIP': AddrZIP,
                    'AddrPhone': AddrPhone,
                    'AddrPhone1': AddrPhone1,
                    'AddrWebsite': AddrWebsite,
                    'AddrCountry': country}

        rc = gL.dbAssettAddress(Asset, AddrList)  
    
        # gestione dei tag
        
        x = content.xpath("//td[contains(., 'Tipo di cucina')]/following-sibling::td/a/text()")   # classificazione
        if len(x)>0:
            tag = []
            #tag.append("Cucina")
            cucina = " ".join(x[0].split())
            tag.append(cucina)
            rc = gL.dbAssetTag(Asset, tag, "Cucina")
        # 
        # Gestione prezzo
        # 
        y = content.xpath('//td[contains(., "Fascia di prezzo")]/following-sibling::td/text()')
        if len(y)>0:
            x = y[0]
            x = gL.StdCar(x)
        PriceFrom = PriceTo = PriceAvg = 0
        if x is not None:
            if x == "bassa":
                PriceFrom = 5
                PriceTo = 12
            if x == "medio-bassa":
                PriceFrom = 12
                PriceTo = 25
            if x == "media":
                PriceFrom = 25
                PriceTo = 40
            if x == "medio-alta":
                PriceFrom = 40
                PriceTo = 60
            if x == "alta":
                PriceFrom = 60
                PriceTo = 100

        PriceList = [['PriceCurr', gL.currency],
                    ['PriceFrom', PriceFrom],
                    ['PriceTo', PriceTo]]
        rc = gL.dbAssetPrice(Asset, PriceList, gL.currency)

        # gestione recensioni
        # 
        r = []
        x = content.xpath('//td[@class="rating_value average"]/text()')[0]   # valutazione
        y = content.xpath('//span[@class="count"]/text()')[0]                   # n. recensioni
        if len(x)>0:
            nreview = locale.atoi(x)
        if len(y)>0:
            punt = locale.atoi(y)
        if len(x)>0:
            r.append((nreview, punt))
            
        #rc = gL.AssettReview(Asset, nreview, int(punt))
        if len(r) > 0:
            gL.dbAssetReview(Asset, r)        

    except Exception as err:
        gL.log(gL.ERROR, url)
        gL.log(gL.ERROR, err)
        return False

    return True
开发者ID:micheledalonzo,项目名称:Orange,代码行数:104,代码来源:OrangeParse.py

示例2: ParseViamichelin

# 需要导入模块: import OrangeGbl [as 别名]
# 或者: from OrangeGbl import dbAssetReview [as 别名]

#.........这里部分代码省略.........
        #    LastReviewDate = gL.StdCar(LastReviewDate)
        #    LastReviewDate = LastReviewDate.replace('Recensito il ', '')
        #    LastReviewDate = datetime.datetime.strptime(LastReviewDate, '%d %B %Y')
        #    # aggiorno la data di ultima recensione sulla tabella asset del source
        #    if LastReviewDate != CurAssetLastReviewDate:
        #        gL.cMySql.execute("Update Asset set LastReviewDate=? where Asset=?", (LastReviewDate, Asset))
        indirizzo = ''
        addr = content.xpath('//li[@class="vm-clear"]//li//text()')
        for add in addr:
            if add == ''           or \
               add == ' '          or \
               add == "Vedi mappa" or \
               add == "Indirizzo"  or \
               add == " : \xa0":
                continue
            indirizzo = add
            break
        if indirizzo:
            indirizzo = indirizzo + " " + country       
        AddrPhone= ''; AddrPhone1 = ''
        telefono = (content.xpath('//a[contains(@href, "tel:")]//text()'))
        if len(telefono)>0:
            AddrPhone, AddrPhone1 = gL.StdPhone(telefono[0], country)

        AddrWebsite = ''
        sito = (content.xpath('//li[contains(., "Sito internet")]//@href'))
        if len(sito)>0:
            AddrWebsite = sito[0]
        AddrList = {'AddrStreet': '',
                    'AddrCity': '',
                    'AddrCounty': '',
                    'AddrZIP': '',
                    'AddrPhone': AddrPhone,
                    'AddrPhone1': '',
                    'AddrWebsite': AddrWebsite,
                    'Address': indirizzo,
                    'AddrCountry': country}
        rc = gL.dbAssettAddress(Asset, AddrList) 
       
        # gestione dei tag             
        classify = (content.xpath('//div[@class="fleft"]//text()'))
        #Text=''
        #Text='Cucina :'
        #Text='regionale'
        tag = []
        ok = 0
        for i in classify:
            if (i == '\n') or (i == '') or (i == ' '):
                continue                
            if i == "Cucina :":
                ok = 1
                continue
            if ok == 1:    
                tag.append(i)

        # rimuovo duplicati dalla lista
        rc = gL.dbAssetTag(Asset, tag, "Cucina")
    
        # Gestione prezzo    
        test = content.xpath('//span[@class="priceFrom parseClass itemPoisOn"]//text()')
        #Text='Da'
        #Text='30 EUR'
        #Text='a'
        #Text='56 EUR'
        #Text=''
        PriceFrom = 0; PriceTo = 0
        for idx, a in enumerate(test):
            if a == "  Da " and (len(test) - idx) > 1:
                PriceFrom = test[idx+1].replace(u'EUR', u'')
            if a == " a "  and (len(test) - idx) > 1:
                PriceTo   = test[idx+1].replace(u'EUR', u'')
        PriceList = [['PriceCurr', gL.currency],
                    ['PriceFrom', PriceFrom],
                    ['PriceTo', PriceTo]]
        rc = gL.dbAssetPrice(Asset, PriceList, gL.currency)
    
        # gestione recensioni    
        r = []; punt = 0; nreview = 1 # ispettore viamichelin
        lev1 = content.xpath('//span[@class="pStars1 pRating pStarsImg parseClass"]')
        lev2 = content.xpath('//span[@class="pStars2 pRating pStarsImg parseClass"]')
        lev3 = content.xpath('//span[@class="pStars3 pRating pStarsImg parseClass"]')
        lev4 = content.xpath('//span[@class="pStars4 pRating pStarsImg parseClass"]')   
        if len(lev4) > 0:
            punt = 4
        if len(lev3) > 0:
            punt = 3
        if len(lev2) > 0:
            punt = 2
        if len(lev1) > 0:    # bib gourmand locali ottimo rapporto qualità/prezzo
            punt = 1
        if punt > 0:
            r.append((nreview, punt))
            gL.dbAssetReview(Asset, r)        

    except Exception as err:
        gL.log(gL.ERROR, url)
        gL.log(gL.ERROR, err)
        return False
    
    return True
开发者ID:micheledalonzo,项目名称:Orange,代码行数:104,代码来源:OrangeParse.py

示例3: ParseGooglePlaces

# 需要导入模块: import OrangeGbl [as 别名]
# 或者: from OrangeGbl import dbAssetReview [as 别名]

#.........这里部分代码省略.........
            url = d['url']
        else:
            url = ''
        
        # ---------------------------- INSERISCO L'ASSET
        AddrCity=AddrCounty=AddrZIP=AddrPhone=AddrPhone1=AddrWebsite=AddrLat=AddrLong=AddrRegion=FormattedAddress=AddrCountry=Address=''
        Asset = gL.dbAsset(country, assettype, gL.GoogleSource, nam, url, AAsset, pid)  # inserisco l'asset        
        if Asset == 0:
            return Asset
        rc = gL.dbAssetTag(Asset, tag, "Tipologia")
        rc = gL.dbAssetPrice(Asset, PriceList, gL.currency)
        
        AddrCounty = AddrStreet = AddrNumber = AddrRegion = AddrCity = AddrZIP = ""; 
        for component in d['address_components']:
            a = component['types']
            if a:
                if a[0] == "locality":             
                            AddrCity = component['long_name']     
                if a[0] == "route":             
                            AddrStreet = component['long_name']     
                if a[0] == "administrative_area_level_1":             
                            AddrRegion = component['long_name']     
                if a[0] == "administrative_area_level_2":             
                            AddrCounty = component['short_name']     
                if a[0] == "administrative_area_level_3":             
                            AddrCity = component['long_name']     
                if a[0] == "street_number":             
                            AddrNumber = component['long_name']     
                if a[0] == "postal_code":             
                            AddrZIP = component['long_name']     
    
        AddrStreet = AddrStreet + " " + AddrNumber                    
        if 'international_phone_number' in d:
            if d['international_phone_number']:
                AddrPhone = d['international_phone_number']
            elif d['formatted_phone_number']:
                AddPhone = d['formatted_phone_number']
        
        punt = 0; nreview = 0
        if 'rating' in d:
            punt = d['rating']        
            nreview = d['user_ratings_total']
        if 'website' in d:
            AddrWebsite = d['website']
        if 'geometry' in d:        
            AddrLat  = d['geometry']['location']['lat']
            AddrLong = d['geometry']['location']['lng']        

        AddrValidated = gL.NO
        FormattedAddress = d['formatted_address']
        AddrList = {'AddrStreet': AddrStreet,
            'AddrCity': AddrCity,
            'AddrCounty': AddrCounty,
            'AddrZIP': AddrZIP,
            'AddrPhone': AddrPhone,
            'AddrPhone1': '',
            'AddrWebsite': AddrWebsite,
            'AddrLat': AddrLat,
            'AddrLong': AddrLong,
            'AddrRegion': AddrRegion,
            'FormattedAddress': FormattedAddress,
            'AddrValidated': gL.YES,
            'AddrCountry': country,
            'Address': indirizzo}
        rc = gL.dbAssettAddress(Asset, AddrList) 
                   
        # gestione recensioni    
        if punt and nreview:            
            r = []
            r.append((int(nreview), int(punt)))
            rc = gL.dbAssetReview(Asset, r)
        
        # gestione orario
        if 'opening_hours' in d:        
            ope = d['opening_hours']['periods']
            #orario = namedtuple('orario', 'ggft')
            orario = []
            for item in ope:
                dayo = fro = dayc = to = '0000'
                if 'close' in item:
                    o = item['open']
                    if 'day' in o:
                        dayo = o['day']
                    if 'time' in o:
                        fro = o['time']
                if 'close' in item:
                    c = item['close']
                    if 'day' in c:
                        dayc = c['day']
                    if 'time' in c:
                        to = c['time']

                orario.append((dayo, fro, to))
            rc = gL.dbAssetOpening(Asset, orario)
    
    except Exception as err:        
        gL.log(gL.ERROR, (name + " " + indirizzo), err)
        return False

    return Asset
开发者ID:micheledalonzo,项目名称:Orange,代码行数:104,代码来源:OrangeParse.py

示例4: ParseDuespaghi

# 需要导入模块: import OrangeGbl [as 别名]
# 或者: from OrangeGbl import dbAssetReview [as 别名]

#.........这里部分代码省略.........


        AddrWebsite = ''
        AddrCounty  = ''
        AddrStreet  = ''
        AddrZIP     = ''
        AddrPhone   = ''      
        AddrPhone1  = ''      
        AddrCity    = ''               
        AddrStreet = content.xpath('//span[@itemprop="streetAddress"]/text()')
        AddrCity = content.xpath('//span[@itemprop="addressLocality"]/text()')
        AddrCounty = content.xpath('//span[@itemprop="ADDRESSREGION"]/text()')
        AddrZIP = content.xpath('//span[@itemprop="postalCode"]/text()')
        AddrPhone = content.xpath('//*[@itemprop="telephone"]/text()')            
        AddrWebsite = content.xpath('//a[@itemprop="url"]/@href')
        if AddrStreet:
            AddrStreet = gL.StdName(AddrStreet[0])
        if AddrCity:
            AddrCity = gL.StdName(AddrCity[0])
        if AddrCounty:
            AddrCounty = AddrCounty[0]
        if AddrZIP:
            AddrZIP = gL.StdZip(AddrZIP[0])
        if AddrPhone:
            AddrPhone, AddrPhone1 = gL.StdPhone(AddrPhone[0], country)
        if AddrWebsite:
            AddrWebsite = AddrWebsite[0]
        AddrList = {'AddrStreet': AddrStreet,
                    'AddrCity': AddrCity,
                    'AddrCounty': AddrCounty,
                    'AddrZIP': AddrZIP,
                    'AddrPhone': AddrPhone,
                    'AddrPhone1': AddrPhone1,
                    'AddrWebsite': AddrWebsite,
                    'AddrCountry': country}
        rc = gL.dbAssettAddress(Asset, AddrList)

        # gestione dei tag
        # 
        tag = []
        x = content.xpath('//span[@itemprop="servesCuisine"]//text()')
        y = content.xpath('//p[@class="detail-category"]//text()')
        if x:
            for i in x: 
                #tag.append("Cucina")
                cucina = gL.StdName(i)
                tag.append(cucina)
                gL.dbAssetTag(Asset, tag, "Tipologia")
        if y:
            for i in y: 
                #tag.append("Cucina")
                cucina = gL.StdName(i)
                tag.append(cucina)
                gL.dbAssetTag(Asset, tag, "Tipologia")
        #
        # gestione recensioni
        # 
        nreview = 0
        a = content.xpath('//span[@class="review-counter clearfix"]/text()')
        if a:
            a = a[0]
            b = a.split()
            if b:
                nreview = b[0]
            else:
                nreview = 0
        one = content.xpath('//span[@class="fa icon-farfalla star1 on"]')
        two = content.xpath('//span[@class="fa icon-farfalla star2 on"]')
        thre = content.xpath('//span[@class="fa icon-farfalla star3 on"]')
        four = content.xpath('//span[@class="fa icon-farfalla star4 on"]')
        five = content.xpath('//span[@class="fa icon-farfalla star5 on"]')
        punt = 0; r = []
        if five:
            punt = 5
        elif four:
            punt = 4
        elif thre:
            punt = 3
        elif two:
            punt = 2
        elif one:
            punt = 1
        if punt>0:
            r.append((nreview, punt))
            gL.dbAssetReview(Asset, r)        

        price = content.xpath('//*[@itemprop="priceRange"]/text()')
        if price:
            a = price[0]
            PriceAvg = a.replace('€', '')
            PriceList = [['PriceCur', gL.currency],
                            ['PriceAvg', PriceAvg]]
            rc = gL.dbAssetPrice(Asset, PriceList, gL.currency)
    
    except Exception as err:
        gL.log(gL.ERROR, url)
        gL.log(gL.ERROR, err)
        return False

    return True
开发者ID:micheledalonzo,项目名称:Orange,代码行数:104,代码来源:OrangeParse.py

示例5: ParseTripadvisor

# 需要导入模块: import OrangeGbl [as 别名]
# 或者: from OrangeGbl import dbAssetReview [as 别名]

#.........这里部分代码省略.........
        AddrPhone = content.xpath('//div[@class="fl phoneNumber"]/text()')
   
        if len(AddrStreet)>0:
            AddrStreet = gL.StdName(AddrStreet[0])
        if len(AddrCity)>0:
            AddrCity = gL.StdName(AddrCity[0])
        if len(AddrZIP)>0:
            AddrZIP = gL.StdZip(AddrZIP[0])
        if len(AddrPhone)>0:
            #AddrPhone = gL.StdPhone(AddrPhone[0], country)
            AddrPhone, AddrPhone1 = gL.StdPhone(AddrPhone[0], country)
            if not AddrPhone:
                AddrPhone   = ''; AddrPhone1  = ''
        if len(AddrWebsite)>0:
            AddrWebsite = AddrWebsite[0]

        AddrList = {'AddrStreet': AddrStreet,
                    'AddrCity': AddrCity,
                    'AddrCounty': AddrCounty,
                    'AddrZIP': AddrZIP,
                    'AddrPhone': AddrPhone,
                    'AddrPhone1': AddrPhone1,
                    'AddrCountry': country}
        rc = gL.dbAssettAddress(Asset, AddrList) 
         
        # gestione dei tag
        classify = content.xpath('//div[@class="detail"]//text()')
        tag0 = []
        for i in classify:
            if (i == '\n') or (i == '') or (i == ' '):
                continue                
            tag0.append(i)

        tag = []
        cucina = 0
        for i in tag0:
            x = gL.StdCar(i)
            if x == 'Cucina:':
                cucina = 1
                continue
            if cucina == 1:
                cucina = 0
                i = i.split(',')
                for n in i:
                    n = n.lstrip()
                    tag.append(n)
            else:
                continue

        # rimuovo duplicati dalla lista
        rc = gL.dbAssetTag(Asset, tag, "Cucina")

        # Gestione prezzo        
        price = 0
        cont = 0
        PriceFrom = 0
        PriceTo = 0
        PriceCurr = ''
        for i in tag0:
            if i == 'Fascia prezzo:':
                prezzo = tag0[cont + 1]
                PriceFrom = prezzo.split('-')[0].rstrip()
                PriceTo = prezzo.split('-')[1].lstrip()
                #PriceFrom  = gL.StdCar(PriceFrom)
                #PriceTo    = gL.StdCar(PriceTo)
                break
            cont = cont + 1
        if gL.currency == "EUR":
            if PriceFrom != 0:
                PriceFrom = PriceFrom.replace(u'\xa0€', u'')
            if PriceTo != 0:
                PriceTo = PriceTo.replace(u'\xa0€', u'')

        PriceList = [['PriceCurr', gL.currency],
                     ['PriceFrom', PriceFrom],
                     ['PriceTo', PriceTo]]
        rc = gL.dbAssetPrice(Asset, PriceList, gL.currency)
    
        # gestione recensioni    
        r = []
        for i in range(0, 5):
            punt = str(i + 1)
            mask1 = "\'" + punt + "\'"  # riassunto recensioni
            # mask =
            # '//div[@onclick[contains(.,"value=\'5\'")]]/following-sibling::*/text()'
            mask = '//div[@onclick[contains(.,"value=' + mask1 + '")]]/following-sibling::*/text()'
            nreview = content.xpath(mask)  # num review
            if nreview:
                nreview = locale.atoi(nreview[0])
                r.append((nreview, int(punt)))
            
        #rc = gL.AssettReview(Asset, nreview, int(punt))
        if len(r) > 0:
            gL.dbAssetReview(Asset, r)
    
    except Exception as err:        
        gL.log(gL.ERROR, url, err)
        return False

    return True
开发者ID:micheledalonzo,项目名称:Orange,代码行数:104,代码来源:OrangeParse.py


注:本文中的OrangeGbl.dbAssetReview方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。