################################################################ # WARNING: THIS SCRIPTS OVERWRITES the files, therefore if you did notes in the pdfs etc. this will be lost! # Set the folder to download into destpath = "PATH TO YOUR THE FOLDER FOR THE FILES ON YOUR PC" #destpath = "/home/pbac/tmp/introstatdwn/" #os.path.expanduser('~') #os.unlink(destpath) ################################################################ # Init import requests import os def download_file(baseurl, filename, destpath): os.makedirs(os.path.dirname(destpath+filename), exist_ok=True) response = requests.get(baseurl+filename) with open(destpath+filename, 'wb') as file: file.write(response.content) print(f"File downloaded as {filename}") ################################################################ # Prepare # The urls used urlbook = "https://02402.compute.dtu.dk/enotes/" urlslides = "http://www2.compute.dtu.dk/courses/introstat/" # The file names of the chapters chapternames = ['chapter1-DataVisualization', 'chapter2-ProbabilitySimulation', 'chapter3-StatisticsNormalAssumption', 'chapter4-SimulationBasedStatistics', 'chapter5-SimpleLinearRegression', 'chapter6-MultipleLinearRegression', 'chapter7-ProportionsFrequencyTables', 'chapter8-StatisticsMultigroupANOVA', 'chapterA-formulas'] ################################################################ # Go # The book in the two versions download_file(urlbook, 'book-Introstatistics-Python.pdf', destpath) download_file(urlbook, 'book-Introstatistics.pdf', destpath+'bookR/') # The chapters for nm in chapternames: download_file(urlbook, nm+'-Python.pdf', destpath) download_file(urlbook, nm+'.pdf', destpath+'bookR/') ## The exercises and solutions for i in range(9): download_file(urlbook, f"exercises{i}-Python.pdf", destpath+'exercises/') download_file(urlbook, f"solutions{i}-Python.pdf", destpath+'solutions/') ## The slides for i in range(1,13): download_file(urlslides, f"slides02402/uge{i}.pdf", destpath) download_file(urlslides, f"slides02323/week{i}.pdf", destpath) ## The notebooks and data download_file(urlslides, f"notebooks/some_anova_exam_questions_in_python.ipynb", destpath) download_file(urlslides, f"notebooks/some_anova_exam_questions_in_python.ipynb", destpath) download_file(urlslides, f"data/studentheight.csv", destpath) download_file(urlslides, f"data/air.txt", destpath) download_file(urlslides, f"data/treatment_data.csv", destpath) download_file(urlslides, f"data/malformationsdata.txt", destpath) for i in range(1,13): download_file(urlslides, f"notebooks/Week{i}_python.ipynb", destpath)