本文整理汇总了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)