Last active
March 2, 2024 02:37
-
-
Save syneart/bdd55070e458f084aebc3a120b548af7 to your computer and use it in GitHub Desktop.
To download all Netgear's firmwares
This file contains 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 characters
#!/usr/bin/env python2 | |
# -*- coding:utf-8 -*- | |
# pip2 install requests BeautifulSoup4 wget --user | |
import os, requests, json, re, wget | |
from bs4 import BeautifulSoup | |
root_save_dir_path = r'./netgear/' | |
if not os.path.isdir(root_save_dir_path): | |
os.mkdir(root_save_dir_path) | |
models_res = requests.get('https://www.netgear.com/system/supportModels.json') | |
models_soup = BeautifulSoup(models_res.text, "lxml") | |
parsed_json = json.loads(models_soup.get_text()) | |
for val in parsed_json: | |
val_model = re.sub(r'[\/\\]', '_', val['model']) | |
val_url = val['url'] | |
model_dir_path = root_save_dir_path + '/' + val_model + '/' | |
if not os.path.isdir(model_dir_path): | |
os.mkdir(model_dir_path) | |
if (re.search('(\/\/kb\.)', val_url)): | |
print('[SKIP] This url type is article: ' + val_url) | |
continue | |
val_full_url = 'https://www.netgear.com/' + val_url | |
print('[GET]' + '[' + val_model + ']' + '[' + val_full_url + ']') | |
model_res = requests.get(val_full_url) | |
model_soup = BeautifulSoup(model_res.text, "html.parser") | |
for a_link in model_soup.select('{}'.format('a')): | |
firmware_link = a_link.get('href') | |
try: | |
if (re.search('(\.zip)$', firmware_link)): | |
print('[DOWNLOAD]' + '[' + firmware_link + ']') | |
firmware_save_path = model_dir_path + os.path.basename(firmware_link) | |
if not os.path.isfile(firmware_save_path): | |
wget.download(firmware_link, firmware_save_path) | |
else: | |
print('[SKIP] This file is already exist: ' + firmware_save_path) | |
print('\n') | |
except: | |
pass | |
print('[DONE]' + 'You can find your download\'s files at: ' + root_save_dir_path) |
🤣 I'm about to write a script to dump all Netgear firmwares, but of course it has already been done
🤣 I'm about to write a script to dump all Netgear firmwares, but of course it has already been done
I'm glad I could assist you!
It's impressive that the script content from such a long time ago is still usable.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requirements,
pip install wget beautifulsoup4 lxml