title: python beautiful soup html tag question [updated]
body: <p>I have the following lines in md files</p>
  <pre><code>&lt;td colspan=&quot;1&quot; class=&quot;IDtd&quot;&gt;
  &lt;p&gt;
  &lt;a class=&quot;external-link&quot; href=&quot;https://link/browse/DDDD-3194&quot; rel=&quot;nofollow&quot;&gt;DDDD-3194&lt;/a&gt; - &lt;span&gt;number of total submissions&lt;/span&gt;
  &lt;/p&gt;
  &lt;/td&gt;
  
  &lt;td class=&quot;IDtd&quot;&gt;
  &lt;a href=&quot;https://link/browse/EEEE-2543&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://link/browse/EEEEE-2543&lt;/a&gt;
  &lt;/td&gt;
  
  [AAAA-4444](https://link/browse/AAAA-4444) - BO NANO : UAT Findings
  
  &lt;td class=&quot;IDtd&quot;&gt;Some_text EEE-123411 Other text&lt;/td&gt;
  </code></pre>
  <p>My questions are:</p>
  <ol>
  <li>How can I check using beautiful soup the the next line after TD is html tag or text?</li>
  <li>How can I add html commecnt in all links (html and md) following with an ID?</li>
  </ol>
  <p>The expected output for the 2nd question is</p>
  <pre><code>&lt;td colspan=&quot;1&quot; class=&quot;IDtd&quot;&gt;
  &lt;p&gt;
  &lt;!-- 
  &lt;a class=&quot;external-link&quot; href=&quot;https://link/browse/DDDD-3194&quot; rel=&quot;nofollow&quot;&gt;DDDD-3194&lt;/a&gt; 
  --&gt; #ID - &lt;span&gt;number of total submissions&lt;/span&gt;
  &lt;/p&gt;
  &lt;/td&gt;
  
  &lt;td class=&quot;IDtd&quot;&gt;
  &lt;!--
  &lt;a href=&quot;https://link/browse/EEEE-2543&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://link/browse/EEEEE-2543&lt;/a&gt; 
  --&gt; #ID
  &lt;/td&gt;
  
  &lt;!--
  [AAAA-4444](https://link/browse/AAAA-4444) - BO NANO : UAT Findings
  --&gt; #ID
  
  </code></pre>
  <p>For the first question I found this</p>
  <pre><code>html = &quot;&quot;&quot;
  &lt;td colspan=&quot;1&quot; class=&quot;IDtd&quot;&gt;
  &lt;p&gt;
  &lt;a class=&quot;external-link&quot; href=&quot;https://_jira_link/browse/DDDD-3194&quot; rel=&quot;nofollow&quot;&gt;DDDD-3194&lt;/a&gt; - &lt;span&gt;number of total submissions&lt;/span&gt;
  &lt;/p&gt;
  &lt;/td&gt;
  
  &lt;td class=&quot;IDtd&quot;&gt;
  &lt;a href=&quot;https://_jira_link/jira/browse/EEEE-2543&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://_jira_link/browse/EEEEE-2543&lt;/a&gt;
  &lt;/td&gt;
  
   &quot;&quot;&quot;
  soup = BeautifulSoup(html)
  tds = soup.find_all(&quot;td&quot;, {&quot;class&quot;:&quot;IDtd&quot;})
  for td in tds:
       p = td.find_all(&quot;p&quot;) # you get list
       if p:
           a = soup.find_all(&quot;a&quot;)
           if a:
               print(&quot;Anchor text is: &quot; + a[0].get_text())
               continue
           print(&quot;P text is: &quot; + p[0].get_text())
           continue
       else:
           print(&quot;No P and A tags found&quot;)
  </code></pre>
  <p>Thank you in advanced</p>