BeautifulSoup

E

elsa

Hi all,

if I have some HTML that looks like this:

<area coords="427,724,432,732" href="http://BioCyc.org/ECOLI/NEW-IMAGE?
type=GENE-IN-CHROM-BROWSER&amp;object=EG12309" onmouseover="return
overlib('&lt;b&gt;Gene:&lt;/b&gt; yjtD&lt;BR&gt;&lt;b&gt;Product:&lt;/
b&gt; predicted rRNA methyltransferase, subunit of predicted rRNA
methyltransferase&lt;BR&gt;&lt;b&gt;Intergenic distances (bp):&lt;/
b&gt; yjjY&lt; +400 yjtD +214 &gt;thrL');"> said:
<b>Product:</b> predicted rRNA methyltransferase, subunit of
predicted rRNA methyltransferase<br /><b>Intergenic distances (bp):</
b> yjjY< +400 yjtD +214 >thrL');" onmouseout="return nd();">
</area>

is there an easy way to use BeautifulSoup to extract just the value of
the href attribute?

Thanks,

elsa
 
P

Peter Otten

elsa said:
if I have some HTML that looks like this:

<area coords="427,724,432,732" href="http://BioCyc.org/ECOLI/NEW-IMAGE?
type=GENE-IN-CHROM-BROWSER&amp;object=EG12309" onmouseover="return
overlib('&lt;b&gt;Gene:&lt;/b&gt; yjtD&lt;BR&gt;&lt;b&gt;Product:&lt;/
b&gt; predicted rRNA methyltransferase, subunit of predicted rRNA
methyltransferase&lt;BR&gt;&lt;b&gt;Intergenic distances (bp):&lt;/
b&gt; yjjY&lt; +400 yjtD +214 &gt;thrL');"> said:
<b>Product:</b> predicted rRNA methyltransferase, subunit of
predicted rRNA methyltransferase<br /><b>Intergenic distances (bp):</
b> yjjY< +400 yjtD +214 >thrL');" onmouseout="return nd();">
</area>

is there an easy way to use BeautifulSoup to extract just the value of
the href attribute?
from BeautifulSoup import BeautifulSoup as BS
html = "<area ..."
BS(html).find("area")["href"]
u'http://BioCyc.org/ECOLI/NEW-IMAGE?\ntype=GENE-IN-CHROM-
BROWSER&object=EG12309'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top