Skip to content

Instantly share code, notes, and snippets.

@MeBlackHat
Forked from menushka/downloadiOSHeaders.py
Last active June 25, 2023 15:58
Show Gist options
  • Save MeBlackHat/d80eee53e2e90272d21da1822d3eeca7 to your computer and use it in GitHub Desktop.
Save MeBlackHat/d80eee53e2e90272d21da1822d3eeca7 to your computer and use it in GitHub Desktop.
Download iOS Headers from http://developer.limneos.net. Includes settings for iOS version, download path and only downloading select frameworks.
from lxml import html
import requests
import re
import os
def createDir(path):
if not os.path.exists(path): os.makedirs(path)
# Settings
iosVersion = "14.4"
downloadOnly = ["SpringBoard", "NotificationCenter", "UserNotifications", "UserNotificationsKit", "UserNotificationsServer", "UserNotificationsUI", "UserNotificationsUIKit"]
downloadPath = "./Headers"
mainPageLink = "http://developer.limneos.net/index.php?ios={}"
downloadPageLink = "http://developer.limneos.net/headers/{}/{}/Headers/{}"
frameworkLinkRegex = "\?ios=.*&framework=(.*)"
headerLinkRegex = "\?ios=.*&framework=.*&header=(.*)"
main = mainPageLink.format(iosVersion)
page = requests.get(main, verify=False)
tree = html.fromstring(page.content)
frameworks = tree.xpath('/html/body/div[@id="container"]/div/a/@href')
headerDownloads = []
for frameworkLink in frameworks:
frameworkName = re.search(frameworkLinkRegex, frameworkLink)
frameworkName = frameworkName.group(1) if frameworkName is not None else None
if frameworkName.replace(".framework", "") not in downloadOnly and len(downloadOnly) != 0: continue
frameworkPage = requests.get(main.split("?")[0] + frameworkLink, verify=False)
frameworkTree = html.fromstring(frameworkPage.content)
headers = frameworkTree.xpath('/html/body/div[@id="container"]/div/a/@href')
for headerLink in headers:
headerFileName = re.search(headerLinkRegex, headerLink)
headerFileName = headerFileName.group(1) if headerFileName is not None else None
if headerFileName is None: continue
headerDownloads.append([frameworkName, headerFileName])
numOfDownloads = len(headerDownloads)
maxDigits = str(len(str(numOfDownloads)))
progressStringFormat = "{:" + maxDigits + "d}/{:" + maxDigits + "d}"
stringFormat = "(" + progressStringFormat + ") {:13}:{} - {}"
for i in range(len(headerDownloads)):
download = headerDownloads[i]
downloadLink = downloadPageLink.format(iosVersion, download[0], download[1])
savePath = os.path.join(downloadPath, download[0], download[1])
if os.path.isfile(savePath):
print(stringFormat.format(i, numOfDownloads, "Skipping", download[0], download[1]));
continue
else:
createDir(os.path.join(downloadPath, download[0]))
print(stringFormat.format(i, numOfDownloads, "Downloading", download[0], download[1]));
r = requests.get(downloadLink, verify=False)
with open(savePath, 'wb') as out:
out.write(r.content)
@MeBlackHat
Copy link
Author

MeBlackHat commented Apr 23, 2021

Fixed SSLError : certificate verify failed

Make use you install lxml using, pip3 install lxml

OG code by @menushka

@freysie
Copy link

freysie commented Jun 25, 2023

what a lovely script!! ヽ(♡‿♡)ノ to get rid of the warnings, add this up top:

import urllib3

urllib3.disable_warnings()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment