title: How to add a new div tag in an existing html file after a h1 tag using python
body: <p>I have a html file and i want to add a div tag after h1 tag. the div tag will have a anchor tag. how can i edit the existing html file using python and add the div with link 
   this is what i want to do </p>
  
  <pre><code>&lt;h1&gt;
  &lt;/h1&gt;
  &lt;div&gt; &lt;a&gt;&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>i tried with BeatifulSoup. got AttributeError: 'NoneType' object has no attribute 'insert_after' this error:</p>
  
  <pre><code>htmlFile ='path to html file' 
  soup = Soup(htmlFile) 
  headTag = soup.find('h1') 
  divTag = soup.new_tag('div') 
  divTag['class'] = "link" 
  headTag.insert_after(divTag)
  </code></pre>
  
  <p>pls suggest to modify this code to add the div tag in the current html file</p>