コード例 #1
0
async def test_search_apa_with_clusters_async():
    gen = craigslist.search_async('washingtondc',
                                  'apa',
                                  postal=20071,
                                  search_distance=1)
    async for post in aislice(gen, 0,
                              200):  # force getting at least one cluster
        pass
コード例 #2
0
async def test_search_apa_async():
    gen = craigslist.search_async('washingtondc',
                                  'apa',
                                  postal=20071,
                                  search_distance=1)
    posts = [post async for post in gen]

    gen2 = craigslist.search('washingtondc',
                             'apa',
                             postal=20071,
                             search_distance=1)
    posts2 = [post for post in gen2]

    sort = lambda x: sorted(x, key=lambda y: y.id)
    assert sort(posts) == sort(posts2)
コード例 #3
0
async def test_search_apa_with_detail_async():

    sleep()

    gen = craigslist.search_async('washingtondc',
                                  'apa',
                                  postal=20071,
                                  search_distance=0.1,
                                  get_detailed_posts=True)
    posts = [post async for post in gen]

    sleep()

    gen2 = craigslist.search('washingtondc',
                             'apa',
                             postal=20071,
                             search_distance=0.1,
                             get_detailed_posts=True)
    posts2 = [post for post in gen2]

    sort = lambda x: sorted(x, key=lambda y: y.id)
    assert sort(posts) == sort(posts2)
コード例 #4
0
async def main():
    async for post in craigslist.search_async('washingtondc',
                                              'apa',
                                              postal=20071,
                                              search_distance=1):
        print(post)