本文整理汇总了Python中cache.Cache.markPropertyAsSeen方法的典型用法代码示例。如果您正苦于以下问题:Python Cache.markPropertyAsSeen方法的具体用法?Python Cache.markPropertyAsSeen怎么用?Python Cache.markPropertyAsSeen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cache.Cache
的用法示例。
在下文中一共展示了Cache.markPropertyAsSeen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from cache import Cache [as 别名]
# 或者: from cache.Cache import markPropertyAsSeen [as 别名]
def main():
# config goes here
suburbs = [
"Dee Why, sydney",
"Cronulla, sydney",
"Caringbah, sydney",
"Miranda, sydney",
"kirrawee, sydney",
"Maroubra, sydney",
"South Coogee, sydney",
"Coogee, sydney",
"Clovelly, sydney",
"Bondi, sydney",
"North Curl Curl, sydney",
"Freshwater, sydney",
"manly, sydney",
]
# always exclude results that mention these words
wordsToExclude = []
numberOfBedRooms = "TWO"
maxPricePerWeek = 700
destinationEmailAddress = "[email protected]"
search_distance_in_meters = 2900
totalListings = []
for suburb in suburbs:
location = googleMapsApiClient.getLatLong(suburb)
lat = location[0]
long = location[1]
listing_results = homeKoalaApiClient.getListings(
lat, long, search_distance_in_meters, numberOfBedRooms, maxPricePerWeek
)
stats = homeKoalaApiClient.getStats(lat, long, search_distance_in_meters, numberOfBedRooms, maxPricePerWeek)
cache = Cache()
# also get any additional information we need.
for x in listing_results["results"]:
details = homeKoalaApiClient.getListingDetail(x["sourceId"])
x["source_url"] = details["sourceUrl"]
x["monthly_price"] = getMonthlyPrice(x["askingPrice"])
x["min_price"] = getMonthlyPrice(stats["min"]["askingPrice"])
x["median_price"] = getMonthlyPrice(stats["median"]["askingPrice"])
x["max_price"] = getMonthlyPrice(stats["max"]["askingPrice"])
if "frontCoverUrl" in x: # sometimes, no img....
x["img_url"] = "https://www.homekoala.com/c/au?url=%s" % (urllib.quote_plus(x["frontCoverUrl"]))
else:
x["img_url"] = ""
x["url_link"] = "https://www.homekoala.com/map/p/%s/?sb=r&c.d.pf=RENT&c.r.pz=%s,%s%%7C%s" % (
x["sourceId"],
lat,
long,
search_distance_in_meters,
)
# print "%s, %s %s %s" % (x["pTitle"],x["min_price"],x["median_price"],x["max_price"])
shouldInclude = True
for word in wordsToExclude:
shouldInclude = not (word.lower() in x["pTitle"].lower()) and not (
word.lower() in details["description"].lower()
)
if not shouldInclude:
print ("excluding " + x["pTitle"] + " coz word found: " + word)
break
if cache.haveSeenProperty(x["sourceId"]):
shouldInclude = False
if shouldInclude:
totalListings.append(x)
# mark as seen
cache.markPropertyAsSeen(x["sourceId"])
if len(totalListings) > 0:
emailService.sendEmail(totalListings, destinationEmailAddress)
print "%s: %s houses sent via email to %s" % (
datetime.datetime.now(),
len(totalListings),
destinationEmailAddress,
)
else:
print "%s: No new updates today" % (datetime.datetime.now())