Skip to content

Instantly share code, notes, and snippets.

@Sunbelife
Last active March 6, 2018 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sunbelife/1f7e5d2935e9e5852f9302701e4a1514 to your computer and use it in GitHub Desktop.
Save Sunbelife/1f7e5d2935e9e5852f9302701e4a1514 to your computer and use it in GitHub Desktop.
Get latest Apple Beta Version from Apple Developer Releases.rss
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import feedparser
import os
import json
import time
def getinfo(oristr, finstr, offset):
index = oristr.find(finstr)
return oristr[index:index+offset]
r = feedparser.parse('http://developer.apple.com/news/releases/rss/releases.rss')
wwwroot = '' # type your path here
entries = r.entries
data_json = os.path.join(wwwroot, 'data.json')
# load data
with open(data_json,"r") as f:
load_dict = json.load(f)
orimacOS = load_dict['macOS']
oriiOS = load_dict['iOS']
oriwatchOS = load_dict['watchOS']
oriupdated = r.feed.updated
macOS = ''
iOS = ''
watchOS = ''
for e in entries:
value = e.content[0].value
if 'beta' in value:
if 'macOS' in value:
macOS = value
elif 'iOS' in value:
iOS = value
elif 'watchOS' in value:
watchOS = value
if len(iOS) > 26 or len(iOS) == 0:
iOS = getinfo(macOS, 'iOS ', 26)
if len(watchOS) > 30 or len(watchOS) == 0:
watchOS = getinfo(macOS, 'watchOS ', 30)
if len(macOS) > 30 or len(macOS) == 0:
macOS = getinfo(macOS, 'macOS ', 30)
updated = oriupdated[:22]
struct_time = time.strptime(updated,"%a, %d %b %Y %H:%M")
updated = str(struct_time[0]) + "." + str(struct_time[1]) + "." + str(struct_time[2])
# updated?
if len(macOS) == 0:
macOS = orimacOS
if len(iOS) == 0:
iOS = oriiOS
if len(watchOS) == 0:
watchOS = oriwatchOS
data = {'macOS':macOS,'iOS':iOS,'watchOS':watchOS,'updated':updated}
print data
if os.path.exists(data_json):
os.remove(data_json)
with open(data_json,"w") as f:
json.dump(data, f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment