Skip to content

Commit

Permalink
Java client fix
Browse files Browse the repository at this point in the history
  • Loading branch information
twkrol committed Sep 27, 2020
1 parent e2c515b commit df94d1a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions clients/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import copy
import urllib.request
import re
import json
from datetime import datetime, date
from bs4 import BeautifulSoup

Expand All @@ -14,10 +15,19 @@

def getReleaseDate():
# Looking for release date
body = urllib.request.urlopen("https://www.java.com/en/download/faq/release_dates.xml").read()
# url = "https://www.java.com/en/download/faq/release_dates.xml"

#grab data
url = "https://www.java.com/content/published/api/v1.1/items/.by.slug/release_dates.html/variations/language/en?fields=all&slug=release_dates.html&channelToken=1f7d2611846d4457b213dfc9048724dc"
data = urllib.request.urlopen(url).read()
jsonData = json.loads(data.decode('utf-8'))
body = jsonData['fields']['answer'][0]

#decode data
soup = BeautifulSoup(body, "html5lib")
value = soup.find('table', {'class': 'lined'}).find_next('tr').find_next('td').find_next('td').get_text()
value = soup.find('table', {'class': 'lined'}).find_next('tr').find_next('tr').find_next('td').find_next('td').get_text()
result = datetime.strptime(value, '%B %d, %Y').date() # date format example: March 7, 2017

return result


Expand All @@ -31,6 +41,7 @@ def getEditions(template):

# Looking for releases
body = urllib.request.urlopen("http://javadl-esd-secure.oracle.com/update/baseline.version").read()

version = str(body, 'utf-8').split('\n', 1)[1]
regex = re.search('(\d+)\.(\d+)\.(\d+)_(\d+)', version)

Expand Down
4 changes: 2 additions & 2 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from datetime import datetime, date
import vergrabber

__version__ = '3.4.0'
__version__ = '3.4.1'
__author__ = 'Tomasz Krol'
__author_email__ = '[email protected]'

debug = False
debug_module = None
# debug = True
# debug_module = 'symfony'
# debug_module = 'java'

def dumper(obj):
if isinstance(obj, date) or isinstance(obj, datetime):
Expand Down

0 comments on commit df94d1a

Please sign in to comment.