예제 #1
0
def TestCnWeiboCrawler(user, pwd):

    uid = 10029
    # uid = 10057
    # uid = 10111
    # uid = 10145
    # uid = 10211
    # uid = 10318
    # uid = 10361
    # uid = 10392

    store_path = './file/'

    fetcher = CnWeiboFetcher(username=user, password=pwd)

    start = time.time()

    login_ok = fetcher.check_cookie()

    if not login_ok:
        print 'login failed.'
        sys.exit()

    fetcher.n_connections = 0
    print 'crawl follows'
    crawler = CnWeiboCrawler(fetcher, store_path, uid=uid)
    crawler.crawl_follows()

    fetcher.n_connections = 0
    print 'crawl fans'
    crawler = CnWeiboCrawler(fetcher, store_path, uid=uid)
    crawler.crawl_fans()

    cost_time = int(time.time() - start)

    print 'finished: # connections: %s, cost time: %s' % (
        fetcher.n_connections, cost_time)
def TestCnWeiboCrawler(user, pwd):
    
    uid = 10029
    # uid = 10057
    # uid = 10111
    # uid = 10145
    # uid = 10211
    # uid = 10318
    # uid = 10361
    # uid = 10392

    store_path = './file/'

    fetcher = CnWeiboFetcher(username=user, password=pwd)

    start = time.time()
    
    login_ok = fetcher.check_cookie()
    
    if not login_ok:
        print 'login failed.'
        sys.exit()
    
    fetcher.n_connections = 0
    print 'crawl follows'
    crawler = CnWeiboCrawler(fetcher, store_path, uid=uid)
    crawler.crawl_follows()
    
    fetcher.n_connections = 0
    print 'crawl fans'
    crawler = CnWeiboCrawler(fetcher, store_path, uid=uid)
    crawler.crawl_fans()
     
    cost_time = int(time.time() - start)    
    
    print 'finished: # connections: %s, cost time: %s' %(fetcher.n_connections, cost_time)