grapplerulrich commited on
Commit
ea2fb58
1 Parent(s): 2164d57

Do not save just spaces

Browse files
Files changed (1) hide show
  1. beautiful_soup/app.py +6 -2
beautiful_soup/app.py CHANGED
@@ -23,7 +23,7 @@ def get_url_content( url ):
23
  except Exception as exception:
24
  raise exception
25
  with open( file_path, 'w' ) as file:
26
- file.write( content )
27
 
28
  return content
29
 
@@ -40,7 +40,11 @@ def extract_content( url ):
40
  if content is None :
41
  raise Exception('No main content found.')
42
 
43
- return get_tags_text( content )
 
 
 
 
44
 
45
  # Make request and get html content.
46
  def get_soup( url ):
 
23
  except Exception as exception:
24
  raise exception
25
  with open( file_path, 'w' ) as file:
26
+ file.write( content.strip() )
27
 
28
  return content
29
 
 
40
  if content is None :
41
  raise Exception('No main content found.')
42
 
43
+ text = get_tags_text( content )
44
+ if text is None :
45
+ raise Exception('No text found.')
46
+
47
+ return text
48
 
49
  # Make request and get html content.
50
  def get_soup( url ):