Last active
June 24, 2020 10:32
-
-
Save drizzt/6d9d371ca4ce80f7c47d0812ad874f14 to your computer and use it in GitHub Desktop.
Revisions
-
drizzt created this gist
Jun 24, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ #!/usr/bin/python3 import json import uuid import lxml.html import requests def main(): """ Displays URLs for Windows 10 ISO download from Microsoft. """ sessionId = uuid.uuid4() r = requests.get( 'https://www.microsoft.com/en-us/software-download/windows10ISO') root = lxml.html.fromstring(r.text) downloadPageId = root.xpath('//div[@id="SoftwareDownload_DownloadLinks"]/' '@data-defaultpageid')[0] languagePageId = root.xpath('//div[@id="SoftwareDownload_' 'LanguageSelectionByProductEdition"]/' '@data-defaultpageid')[0] # Get skuId of English r = requests.post('https://www.microsoft.com/en-us/api/' 'controls/contentinclude/html?' f'pageId={languagePageId}' '&host=www.microsoft.com&' 'segments=software-download,windows10ISO' '&query=&action=getskuinformationbyproductedition' f'&sessionId={sessionId}' '&productEditionId=1626&sdVersion=2') root = lxml.html.fromstring(r.text) for option in root.xpath('//option'): if option.text == 'English': skuId = json.loads(option.get('value'))['id'] break r = requests.post('https://www.microsoft.com/en-us/api/' 'controls/contentinclude/html?' f'pageId={downloadPageId}' '&host=www.microsoft.com&' 'segments=software-download,windows10ISO' '&query=&action=GetProductDownloadLinksBySku' f'&sessionId={sessionId}' f'&skuId={skuId}&language=English&sdVersion=2') root = lxml.html.fromstring(r.text) for url in root.xpath('//div[@class]/a/@href'): print(url) if __name__ == '__main__': main()