本文整理匯總了Python中Filter.isExist方法的典型用法代碼示例。如果您正苦於以下問題:Python Filter.isExist方法的具體用法?Python Filter.isExist怎麽用?Python Filter.isExist使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Filter
的用法示例。
在下文中一共展示了Filter.isExist方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __save
# 需要導入模塊: import Filter [as 別名]
# 或者: from Filter import isExist [as 別名]
def __save(self, hotels):
for hotel in hotels:
bfStr = hotel["name"] + hotel["lat"] + hotel["lon"]
# Bloom Filter
exist = Filter.isExist(bfStr)
if not exist :
#insert into database and get hotel's review
id = hotel["id"]
print id
eurl = self.eurl_prefix + str(id) +"/"
detail_code = requests.get(eurl)
soup = BeautifulSoup(detail_code.text, "html.parser")
en_name = soup.find('h1',{'itemprop':'name'}).string
if en_name is None:
en_name = hotel["name"]
en_score = soup.find('strong',{'itemprop':'ratingValue'})
if en_score is None:
en_score = '3'
else:
en_score = soup.find('strong',{'itemprop':'ratingValue'}).string
star = 4
if hotel["star"] == 'hotel_halfdiamond06':
star = 5.5
elif hotel["star"] == 'hotel_stars05':
star = 5.0
elif hotel["star"] == 'hotel_halfdiamond05':
star = 4.5
elif hotel["star"] == 'hotel_stars04':
star = 4.0
sql = "insert into hotel(name_cn,name_en,rating_cn,rating_en,starCount,latitude,longitude,originalHotelID,source) values(\"" \
+ hotel["name"] +"\",\""+ en_name +"\","+ hotel["score"] +","+ en_score + ","+ str(star) + ",\"" \
+ hotel["lat"] +"\",\""+hotel["lon"] +"\",\""+hotel["id"]+"\",\"c\")"
print sql
rowid = DB.insert(sql)
print rowid
self.__save_review(rowid,id)
Filter.addItem(bfStr)