当前位置: 首页>>代码示例>>Python>>正文


Python Cache.markPropertyAsSeen方法代码示例

本文整理汇总了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())
开发者ID:dedril,项目名称:homeKoalaEmailer,代码行数:94,代码来源:main.py


注:本文中的cache.Cache.markPropertyAsSeen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。