def download(self): self.soup = hp.getSoup(self.url) if self.soup == None: print("download book err %s"%(url)) else: options = self.soup.select(".option a") for option in options: if "下载" in option.text: self.downloadSoup = hp.getSoup(option.attrs["href"]) if self.downloadSoup != None: for lk in self.downloadSoup.select(".main .downlink a"): if hp.downloadFile(lk.attrs["href"], self.dirPath, self.url): return
#!/bin/env python #coding: utf-8 import hp import os import re import glob import bs4 if __name__=="__main__": for filePath in glob.glob(os.path.abspath(".") + "/sb/*/*/PICURL"): dirPath = os.path.join(os.path.split(filePath)[0], "PIC") if os.path.exists(dirPath) == False: os.makedirs(dirPath) f = open(filePath) for url in f.readlines(): hp.downloadFile(url, dirPath, "") f.close()
#!/bin/env python #coding: utf-8 import hp import os import re import glob import bs4 if __name__ == "__main__": for filePath in glob.glob(os.path.abspath(".") + "/sb/*/*/PICURL"): dirPath = os.path.join(os.path.split(filePath)[0], "PIC") if os.path.exists(dirPath) == False: os.makedirs(dirPath) f = open(filePath) for url in f.readlines(): hp.downloadFile(url, dirPath, "") f.close()