File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 3030
3131import os
3232import sys
33- import urllib . request
33+ import requests
3434
3535import numpy as np
3636import pandas as pd
@@ -451,12 +451,12 @@ def test_cancer_data():
451451 print ("Hello!\n Start test SVM using the SMO algorithm!" )
452452 # 0: download dataset and load into pandas' dataframe
453453 if not os .path .exists (r"cancer_data.csv" ):
454- request = urllib . request . Request ( # noqa: S310
454+ response = requests . get (
455455 CANCER_DATASET_URL ,
456456 headers = {"User-Agent" : "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)" },
457457 )
458- response = urllib . request . urlopen ( request ) # noqa: S310
459- content = response .read (). decode ( "utf-8" )
458+ response . raise_for_status ( ) # Raise an exception for bad status codes
459+ content = response .text
460460 with open (r"cancer_data.csv" , "w" ) as f :
461461 f .write (content )
462462
You can’t perform that action at this time.
0 commit comments