title: Grab the parent id tag with beautiful soup?
body: <p>Im grabbing a bunch of links fra a website and print them out to a list but to make the list a bit more readable i need to grab the links parent  tag but i cant figure out how to do it.</p>
  
  <p>the page im grabbing from looks like this </p>
  
  <pre><code>&lt;div id=bunch_of_links_1&gt;
  &lt;a href=link 1&gt;
  &lt;a href=link 2&gt;
  &lt;a href=link etc&gt; 
  &lt;/div&gt;
  &lt;div id=another_bunch_of_links_1&gt;
  &lt;a href=another_link 1&gt;
  &lt;a href=another_link 2&gt;
  &lt;a href=another_link etc&gt; 
  &lt;/div&gt;
  </code></pre>
  
  <p>all the links start with javascript so im using this to grab the links</p>
  
  <pre><code>links = soup.findAll(href=re.compile("javascript"))
  </code></pre>
  
  <p>and then print them all using a for loop. How should i go about getting the div id for each link and print it together with the link </p>
  
  <p>EDIT - im not sure where to inset the  [(l, l.parent.get('id')) for l in links]</p>
  
  <p>heres is my code </p>
  
  <pre><code>links = soup.findAll(href=re.compile("javascript"))
  
  for link in links:
  full_link = link.get('href')
  names = link.contents[0]
  print "+names+", "+full_link+"
  </code></pre>
  
  <p>I want to be able to print the Id tag together with the others</p>
  
  <p>EDIT 2</p>
  
  <p>I sat this into my for loop</p>
  
  <pre><code> idtag = link.parent.get('id')
  </code></pre>
  
  <p>and it does not give me any errors by when i print the idtag var it return none</p>