Skip to content

Instantly share code, notes, and snippets.

@syneart
Last active March 2, 2024 02:37
Show Gist options
  • Save syneart/bdd55070e458f084aebc3a120b548af7 to your computer and use it in GitHub Desktop.
Save syneart/bdd55070e458f084aebc3a120b548af7 to your computer and use it in GitHub Desktop.
To download all Netgear's firmwares
#!/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)
@syneart
Copy link
Author

syneart commented Feb 22, 2020

Requirements,
pip install wget beautifulsoup4 lxml

@wblondel
Copy link

wblondel commented Feb 1, 2024

🤣 I'm about to write a script to dump all Netgear firmwares, but of course it has already been done

@syneart
Copy link
Author

syneart commented Mar 2, 2024

🤣 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