import sys, os
args = sys.argv

if (len(args) <= 1):
    raise ValueError('Please provide source url when calling scraper.py. Example : python scraper.py url output.csv')
else:
    url = args[1]
    if (len(args) == 2):
        filename = url.split('/')[-1].split('.')[0]
        output = filename + ".csv"
        print("No output file specified : using " + output)
    else:
        output = sys.argv[2]
        if not output.endswith(".csv"):
            output = output + ".csv"
    if os.path.isfile(output):
        os.remove(output)
    os.system("scrapy crawl realclearpoliticsSpider -a url="+url+" -o "+output)


@@ -4,219 +4,455 @@
 ort 
-sys, os%0Aargs = sys.argv%0A%0Aif (len(args) %3C= 1):%0A    raise ValueError('Please provide source url when calling scraper.py. Example : python scraper.py url output.csv')%0Aelse:%0A    url = args%5B1%5D%0A    if (len(args) == 2)
+os, scrapy, argparse%0Afrom realclearpolitics.spiders.spider import RcpSpider%0Afrom scrapy.crawler import CrawlerProcess%0Aparser = argparse.ArgumentParser('Scrap realclearpolitics polls data')%0Aparser.add_argument('url', action=%22store%22)%0Aparser.add_argument('--csv', dest='to_csv', action='store_true')%0Aparser.add_argument('--output', dest='output', action='store')%0Aargs = parser.parse_args()%0Aurl = args.url%0A%0Aif (args.to_csv):%0A    if args.output is None
 :%0A  
@@ -627,19 +627,19 @@
 t = 
-sys.argv%5B2%5D
+args.output
 %0A   
@@ -850,8 +850,100 @@
 utput)%0A%0A
+else:%0A    process = CrawlerProcess();%0A    process.crawl(RcpSpider, url)%0A    process.start()%0A

Make csv generation optional