本文整理汇总了Python中OrangeGbl类的典型用法代码示例。如果您正苦于以下问题:Python OrangeGbl类的具体用法?Python OrangeGbl怎么用?Python OrangeGbl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OrangeGbl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ParseGooglePlacesMain
def ParseGooglePlacesMain(Asset, AAsset):
if gL.trace: gL.log(gL.DEBUG)
try:
gL.cMySql.execute("Select * from QAddress where Asset = %s", ([Asset]))
row = gL.cMySql.fetchone()
if not row:
gL.log(gL.ERROR, "asset:" + str(Asset))
return False
country = row['Country']
assettype = row['AssetType']
source = row['Source']
starturl = row['StartUrl']
asseturl = row['AssetUrl']
name = row['name']
address = row['address']
addrstreet = row['addrstreet']
addrcity = row['addrcity']
addrzip = row['addrzip']
addrcounty = row['addrcounty']
gAsset = gL.ParseGooglePlaces(Asset, assettype, name, gL.xstr(addrstreet), gL.xstr(addrzip), gL.xstr(addrcity), gL.xstr(country), gL.xstr(address), AAsset )
return gAsset
except Exception as err:
gL.log(gL.ERROR, "asset:" + str(Asset))
gL.log(gL.ERROR, err)
return False
示例2: NextpageDuespaghi
def NextpageDuespaghi(url, page):
if gL.trace: gL.log(gL.DEBUG)
try:
# DUESPAGHI - PAGINAZIONE - RICEVE UNA PAGINA, E RESTITUISCE URL DELLA NEXT
o = urlparse(url)
found = re.search('pag=(.+?)&', o.query).group(1)
if found is not None:
# l'url della paginazione
nx = int(found) + 1
url_a = "http://" + o.hostname + o.path + "?pag=" + str(nx) + "&ord=relevance&dir=desc"
# controlla che esista
rc, page = ReadPage(url_a)
if rc != 0 or page is None:
return False, ''
#chkstr = '//*[@class="row-identity-container"]/a/@href'
chkstr = '//*[@class="disabled"]//i//@class' # Element='<i class="fa fa-chevron-right" />'
test = page.xpath(chkstr) # le pagine esistono ma non hanno contenuto
if "fa fa-chevron-right" not in test:
return url_a, page
except Exception as err:
url_a = "http://" + o.hostname + o.path + "?pag=2&ord=relevance&dir=desc" # se non trovo il numero pagina vuol dire che è la prima pagina,
# controlla che esista
rc, newpage = ReadPage(url_a)
if rc == 0 and newpage is not None:
test = newpage.xpath('//*[@class="row-identity-container"]/a/@href') # controllo che la seconda esista con del contenuto
if test:
return url_a, newpage
else:
return False, ''
return False, ''
示例3: dbAssetPrice
def dbAssetPrice(Asset, PriceList, currency):
if gL.trace: gL.log(gL.DEBUG)
try:
# cancella e riscrive la classificazione dell'asset
if len(PriceList)>0:
PriceCurr = ""
PriceFrom = 0
PriceTo = 0
PriceAvg = 0
for i in PriceList:
if i[0] == 'PriceCurr':
PriceCurr = i[1]
if i[0] == 'PriceFrom':
PriceFrom = i[1]
if i[0] == 'PriceTo':
PriceTo = i[1]
if i[0] == 'PriceAvg':
PriceAvg = i[1]
if PriceCurr == '':
PriceCurr = currency
if PriceFrom == 0 and PriceTo == 0 and PriceAvg == 0:
pass
else:
gL.cMySql.execute("Delete from AssetPrice where Asset = %s ", ([Asset]))
gL.cMySql.execute("Insert into AssetPrice(Asset, PriceCurrency, PriceFrom, PriceTo, PriceAvg) Values (%s, %s, %s, %s, %s)", (Asset, PriceCurr, PriceFrom, PriceTo, PriceAvg))
return True
except Exception as err:
gL.log(gL.ERROR, err)
return False
示例4: OpenConnectionSqlite
def OpenConnectionSqlite():
if gL.trace: gL.log(gL.DEBUG)
if not gL.SqLite:
gL.SqLite = sqlite3.connect(':memory:')
gL.cLite = gL.SqLite.cursor()
return gL.SqLite, gL.cLite
示例5: ParseAsset
def ParseAsset(country, assettype, source, starturl, pageurl, asseturl, name):
# parse delle singole pagine degli asset
gL.dbQueueStatus("START", country, assettype, source, starturl, pageurl, asseturl) # scrivo nella coda che inizio
Asset = gL.ParseContent(country, assettype, source, starturl, asseturl, name)
if Asset: # se tutto ok
gL.dbQueueStatus("END", country, assettype, source, starturl, pageurl, asseturl) # scrivo nella coda che ho finito
return True
示例6: UpdDriveRun
def UpdDriveRun(startend):
if gL.trace: gL.log(gL.DEBUG)
try:
if startend == "START":
gL.cMySql.execute("Update Drive set RunDate = %s where active = True", ([gL.RunDate]))
if startend == "END":
gL.cMySql.execute("Update Drive set RunDate_end = %s where active = True", ([gL.SetNow()]))
except Exception as err:
gL.log(gL.ERROR, err)
return False
示例7: ParseNextPage
def ParseNextPage(source, assettype, country, pageurl, page):
if gL.trace: gL.log(gL.DEBUG)
try:
fn = gL.GetFunzione("NEXT", source, assettype, country)
if not fn:
raise Exception("Funzione NEXT non trovata")
return globals()[fn](pageurl, page)
except Exception as err:
gL.log(gL.ERROR, err)
return False
示例8: RunIdCreate
def RunIdCreate(RunType):
if gL.trace: gL.log(gL.DEBUG)
try:
runid = 0
gL.cMySql.execute("Insert into Run (Start, RunType) Values (%s, %s)", (gL.SetNow(), RunType))
run = gL.cMySql.lastrowid # recupera id autonum generato
if run is None:
raise Exception("Get autonum generato con errore")
return run
except Exception as err:
return False
示例9: BuildQueue
def BuildQueue(country, assettype, source, starturl, pageurl, page):
if gL.trace: gL.log(gL.DEBUG)
try:
fn = gL.GetFunzione("QUEUE", source, assettype, country)
if not fn:
raise Exception("Funzione QUEUE non trovata")
return globals()[fn](country, assettype, source, starturl, pageurl, page)
except Exception as err:
gL.log(gL.ERROR, err)
return False
示例10: RunIdStatus
def RunIdStatus(startend):
if gL.trace: gL.log(gL.DEBUG)
try:
if startend == "START":
gL.cMySql.execute("Update Run set Start = %s where RunId = %s ", (gL.SetNow(), gL.RunId))
if startend == "END":
gL.cMySql.execute("Update Run set End = %s where RunId = %s ", (gL.SetNow(), gL.RunId))
return True
except Exception as err:
#gL.log(gL.ERROR, err)
return False
示例11: DumpGoogleResults
def DumpGoogleResults(Asset, name, indirizzo, chk):
if gL.trace: gL.log(gL.DEBUG)
if len(chk) == 0:
return
for item in chk:
gL.cMySql.execute("Delete from Debug_GoogleResults where Asset = %s", ([Asset]))
break
for item in chk:
gL.cMySql.execute("Insert into Debug_GoogleResults(Asset, AssetName, AssetAddress, GblRatio, Nome, Address, NameRatio, StreetRatio) \
Values (%s, %s, %s, %s, %s, %s, %s, %s)", \
( Asset, name, indirizzo, item[0], item[2], item[3], item[4], item[5]))
return True
示例12: LoadProxyList
def LoadProxyList():
if gL.trace: gL.log(gL.DEBUG)
try:
gL.cMySql.execute("Select * from RunProxies where Active = %s", ([gL.YES]) )
proxies = gL.cMySql.fetchall()
if len(proxies) == 0:
return False
for proxy in proxies:
gL.Proxies.append(proxy[0])
return True
except Exception as err:
gL.log(gL.ERROR, err)
return False
示例13: dbQueueStatus
def dbQueueStatus(startend, country, assettype, source, starturl, pageurl, asseturl):
if gL.trace: gL.log(gL.DEBUG)
try:
if startend == "START":
gL.cMySql.execute("Update queue set Start=%s, End=0, RunId=%s where Country=%s and AssetType=%s and Source=%s and Starturl=%s and Pageurl=%s and AssetUrl=%s", \
(gL.SetNow(), gL.RunId, country, assettype, source, starturl, pageurl, asseturl))
if startend == "END":
gL.cMySql.execute("Update queue set End=%s, RunId=%s where Country=%s and AssetType=%s and Source=%s and Starturl=%s and Pageurl=%s and AssetUrl=%s", \
(gL.SetNow(), gL.RunId, country, assettype, source, starturl, pageurl, asseturl))
except Exception as err:
gL.log(gL.ERROR, (str(source)+ str(assettype) + country + starturl + pageurl + asseturl), err)
return False
return True
示例14: GetFunzione
def GetFunzione(tipo, source, assettype, country):
if gL.trace: gL.log(gL.DEBUG)
try:
for k in gL.Funzioni:
if k['source'] == source and k['assettype'] == assettype and k['country'] == country:
if tipo == "PARSE":
return k['ParseFn']
if tipo == "QUEUE":
return k['QueueFn']
if tipo == "NEXT":
return k['NextPageFn']
except Exception as err:
gL.log(gL.ERROR, err)
return False
示例15: dbAssetOpening
def dbAssetOpening(Asset, orario):
if gL.trace: gL.log(gL.DEBUG)
try:
gL.cMySql.execute("Delete from AssetOpening where Asset = %s ", ([Asset]))
for j in orario:
x = j[1][:2]+":"+j[1][2:]
y = j[2][:2]+":"+j[2][2:]
gL.cMySql.execute("Insert into AssetOpening(Asset, WeekDay, OpenFrom, OpenTo) Values (%s, %s, %s, %s)", \
(Asset, j[0], x, y))
return True
except Exception as err:
gL.log(gL.ERROR, err)
return False