def dex2jar(apkPath,savePath): """ 解压APK并将dex转为jar :return: bool """ from shutil import move as moveFile from zipfile import ZipFile as unzip from os import popen as cmd try: z = unzip(apkPath, 'r') z.extractall(path=r"{}/files/".format(savePath)) z.close() os.cmd(".\dex2jar\d2j-dex2jar --force ./{}/files/classes.dex".format(savePath)) if os.path.exists("classes-dex2jar.jar"): moveFile("classes-dex2jar.jar", "./{}/{}.jar".format(savePath,apkFile)) return True except Exception as e: # print(e) pass return False
def getFinancialReports(my_bot, tickers, report): """ Downloads an invidiual report from SEC website and saves it to downloads directory """ for ticker in tickers: my_bot.log("searching edgar for %s" % ticker) url = "https://www.sec.gov/edgar/searchedgar/companysearch.html" my_bot.get(url) searchBox = (my_bot.find_by_tag_and_attr(tag="input", attribute="id", evaluation_string="cik", sleep_secs=SLEEPSECONDS))[0] searchBox.clear() searchBox.send_keys(ticker, Keys.ENTER) typeBox = (my_bot.find_by_tag_and_attr(tag="input", attribute="id", evaluation_string="type", sleep_secs=SLEEPSECONDS))[0] time.sleep(4) typeBox.send_keys(report, Keys.ENTER) interactiveFields = (my_bot.find_by_tag_and_attr( tag="a", attribute="id", evaluation_string="interactiveDataBtn", sleep_secs=SLEEPSECONDS)) interactiveFields[0].click() exportExcel = (my_bot.find_by_tag_and_attr( tag="a", attribute="class", evaluation_string="xbrlviewer", sleep_secs=SLEEPSECONDS)) exportExcel = [ el for el in exportExcel if el.text == "View Excel Document" ] exportExcel[0].click() while not len(glob.glob(os.path.join(my_bot.downloads_dir, r"*.xlsx"))) > 0: time.sleep(3) print("waiting for download") exportExcel[0].click() if os.path.exists(os.path.join(my_bot.downloads_dir, ticker)): pass else: os.mkdir(os.path.join(my_bot.downloads_dir, ticker)) downloadedReport = glob.glob( os.path.join(my_bot.downloads_dir, r"*.xlsx"))[0] destination = os.path.join(my_bot.downloads_dir, ticker, "Financial_Report.xlsx") moveFile(downloadedReport, destination) time.sleep(5)
fileTimestamp = datetime.datetime(year=int(datetimeResults[0][0]), month=int(datetimeResults[0][1]), day=int(datetimeResults[0][2]), hour=int(datetimeResults[0][3]), minute=int(datetimeResults[0][4]), second=int(datetimeResults[0][5])) relativeDifference = relativedelta.relativedelta( fileTimestamp, birthday) difference = (relativeDifference.years * 12) + relativeDifference.months folderName = f"Jahr {difference // 12}" subfolderName = f"Monat {difference % 12}" print(f"{folderName} {subfolderName}") yearFolder = os.path.join(targetDir, folderName) monthFolder = os.path.join(targetDir, folderName, subfolderName) currentFilePath = os.path.join(targetDir, filename) targetFilePath = os.path.join(targetDir, folderName, subfolderName, filename) if not os.path.exists(yearFolder): os.mkdir(yearFolder) if not os.path.exists(monthFolder): os.mkdir(monthFolder) moveFile(currentFilePath, targetFilePath)
def _move(source: Path, destination: Path) -> None: moveFile(str(source), str(destination))