#!/usr/bin/env python
# -*- coding: utf-8 -*-


import argparse

from nicocrawler.nicocrawler import NicoCrawler


if __name__ == '__main__':

    parser = argparse.ArgumentParser()
    parser.add_argument('-s', '--sqlite_path',
                        default='comments.sqlite3',
                        help='クロールしたデータを保存するSQLiteの場所')
    parser.add_argument('-c', '--csv_path',
                        default='crawled.csv',
                        help='クロールする予定のURLを集めたCSV')
    args = parser.parse_args()
    sqlite_path = args.sqlite_path
    csv_path = args.csv_path

    ncrawler = NicoCrawler()
    ncrawler.connect_sqlite(sqlite_path)

    url = 'http://ch.nicovideo.jp/2015spring_anime'
    df = ncrawler.get_all_video_url_of_season(url)
    ncrawler.initialize_csv_from_db(csv_path)

    # # デイリーランキング1~300位の動画を取得する
    # url = 'http://www.nicovideo.jp/ranking/fav/daily/all'
    # ncrawler.initialize_csv_from_url(url, csv_path, max_page=3)

    ncrawler.get_all_comments_of_csv(csv_path, max_n_iter=1)

@@ -45,222 +45,187 @@
 -%0A%0A%0A
-import argparse%0A%0Afrom nicocrawler.nicocrawler import NicoCrawler%0A%0A%0Aif __name__ == '__main__':%0A%0A    parser = argparse.ArgumentParser()%0A    parser.add_argument('-s', '--sqlite_path',%0A                        
+__doc__ = '''%0ACrawl comment from nicovideo.jp%0A%0AUsage:%0A    main_crawl.py %5B--sqlite %3Csqlite%3E%5D %5B--csv %3Ccsv%3E%5D%0A%0AOptions:%0A    --sqlite %3Csqlite%3E  (optional) path of comment DB %5B
 default
-='
+: 
 comm
@@ -240,144 +240,95 @@
 ite3
-',
+%5D
 %0A    
-                    help='%E3%82%AF%E3%83%AD%E3%83%BC%E3%83%AB%E3%81%97%E3%81%9F%E3%83%87%E3%83%BC%E3%82%BF%E3%82%92%E4%BF%9D%E5%AD%98%E3%81%99%E3%82%8BSQLite%E3%81%AE%E5%A0%B4%E6%89%80')%0A    parser.add_argument('-c', '--csv_path',%0A                        
+--csv %3Ccsv%3E        (optional) path of csv file contains urls of videos %5B
 default
-='
+: 
 craw
@@ -338,92 +338,165 @@
 .csv
-',%0A                        help='%E3%82%AF%E3%83%AD%E3%83%BC%E3%83%AB%E3%81%99%E3%82%8B%E4%BA%88%E5%AE%9A%E3%81%AEURL%E3%82%92%E9%9B%86%E3%82%81%E3%81%9FCSV')%0A    args = parser.parse_args(
+%5D%0A'''%0A%0A%0Afrom docopt import docopt%0A%0Afrom nicocrawler.nicocrawler import NicoCrawler%0A%0A%0Aif __name__ == '__main__':%0A%0A    # %E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%83%A9%E3%82%A4%E3%83%B3%E5%BC%95%E6%95%B0%E3%81%AE%E5%8F%96%E5%BE%97%0A    args = docopt(__doc__
 )%0A  
@@ -519,20 +519,20 @@
 args
-.
+%5B'--
 sqlite
-_path
+'%5D
 %0A   
@@ -551,17 +551,17 @@
 args
-.csv_path
+%5B'--csv'%5D
 %0A%0A  

Replace argparse with docopt