2017-10-06 57 views
0
def analyze_html(url, root_url): 
    savepath = download_file(url) 
    if savepath is None: 
     return # here 
    if savepath in proc_files: 
     return # here 
    proc_files[savepath] = True 
    print("analyze_html", url) 
    html = open(savepath, "r", encoding="utf-8").read() 
    links = enum_links(html, url) 
    for link_url in links: 
     if link_url.find(root_url) != 0: 
      if not re.search(r".css$", link_url): 
       continue 
     if re.search(r".(html|htm)$", link_url): 
      analyze_html(link_url, root_url) 
      continue 
     download_file(link_url) 

請參閱我用雙星號包裹的if語句。 我覺得在返回後必須有一些東西要歸還。 這是什麼意思?「返回」後可以沒有任何東西嗎?

回答

相關問題