本文整理汇总了Python中OrangeGbl.dbAsset方法的典型用法代码示例。如果您正苦于以下问题:Python OrangeGbl.dbAsset方法的具体用法?Python OrangeGbl.dbAsset怎么用?Python OrangeGbl.dbAsset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrangeGbl
的用法示例。
在下文中一共展示了OrangeGbl.dbAsset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ParseContent
# 需要导入模块: import OrangeGbl [as 别名]
# 或者: from OrangeGbl import dbAsset [as 别名]
def ParseContent(country, assettype, source, starturl, asseturl, name):
if gL.trace: gL.log(gL.DEBUG)
try:
Asset = gL.dbAsset(country, assettype, source, name, asseturl) # inserisco l'asset
if Asset == 0:
raise Exception("Errore nella creazione dell'asset")
fn = gL.GetFunzione("PARSE", source, assettype, country)
if not fn:
raise Exception("Funzione PARSE non trovata")
rc = globals()[fn](country, asseturl, name, Asset)
if rc:
return Asset
else:
raise Exception("Funzione PARSE con errori")
except Exception as err:
gL.log(gL.ERROR, err)
return False
示例2: ParseGooglePlaces
# 需要导入模块: import OrangeGbl [as 别名]
# 或者: from OrangeGbl import dbAsset [as 别名]
#.........这里部分代码省略.........
PriceTo = 25
if prz == 3:
PriceFrom = 26
PriceTo = 60
if prz == 4:
PriceFrom = 60
PriceTo = 100
PriceList = [['PriceCurr', gL.currency],
['PriceFrom', PriceFrom],
['PriceTo', PriceTo]]
# chiedo il dettaglio
detailurl = 'https://maps.googleapis.com/maps/api/place/details/json'
params = dict(
placeid = pid,
key = API_KEY,
language='it',
#types='cafe|reastaurant|bakery|bar|food|meal_takeaway'
)
response = requests.get(url=detailurl, params=params)
data2 = json.loads(response.text)
if data2['status'] != 'OK':
gL.log(gL.WARNING, "GooglePlaces Status " + data['status'])
return False
d = data2['result']
if d['url']:
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