Skip to content

Instantly share code, notes, and snippets.

@menushka
Last active September 17, 2024 18:14
Show Gist options
  • Save menushka/b600c632cb3793bb0ff5e897051fa125 to your computer and use it in GitHub Desktop.
Save menushka/b600c632cb3793bb0ff5e897051fa125 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 = "12.1"
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)
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)
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)
with open(savePath, 'wb') as out:
out.write(r.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment