File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/python3
2- import argparse
32import configparser
43import os
54import re
@@ -187,25 +186,29 @@ def download(url):
187186
188187# Main Logic
189188if __name__ == '__main__' :
190- parser = argparse .ArgumentParser (
191- description = r"Download articles from cool18.com then generate epub." )
192- parser .add_argument ("url" , type = str , help = r"a cool18.com article URL." )
193- args = parser .parse_args ()
189+ args_length = len (sys .argv )
190+ url = None
191+
192+ if (args_length > 1 ):
193+ url = sys .argv [1 ]
194+
195+ if (not url ):
196+ url = str (input ("请粘贴cool18站的文章网址:" ))
194197 loadConfig ()
195198 pypath = sys .argv [0 ]
196199 pydir = os .getcwd ()
197200
198- config ['host' ] = args . url [:args . url .rindex ('/' )+ 1 ]
201+ config ['host' ] = url [:url .rindex ('/' )+ 1 ]
199202
200- src = fetch (args . url )
203+ src = fetch (url )
201204 title = extract_title (src )
202205
203206 if not os .path .exists (title ):
204207 os .mkdir (title )
205208 os .chdir (title )
206209
207210 # Init Hive
208- hive = [args . url ]
211+ hive = [url ]
209212 downloaded = set ()
210213
211214 while hive :
You can’t perform that action at this time.
0 commit comments