Python extract italic content from html
<p>I am trying to extract 'Italic' Content from a pdf in python. I have converted the pdf to html so that I can use the italic tag to extract the text. 
Here is how the html looks like</p>

<pre><code>&lt;br&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="position:absolute; border: textbox 1px
solid; writing-mode:lr-tb; left:71px; top:225px; width:422px;
height:15px;"&gt;&lt;span style="font-family: TTPGFA+Symbol; font-
size:12px"&gt;â¢&lt;/span&gt;&lt;span style="font-family: YUWTQX+ArialMT; font-
size:14px"&gt;  Kornai, Janos. 1992. &lt;/span&gt;&lt;span style="font-family:
PUCJZV+Arial-ItalicMT; font-size:14px"&gt;The Socialist System: The
Political Economy of Communism&lt;/span&gt;&lt;span style="font-family:
YUWTQX+ArialMT; font-size:14px"&gt;.
</code></pre>

<p>This is how the code looks:</p>

<pre><code>from bs4 import BeautifulSoup
soup = BeautifulSoup(open("/../..myfile.html"))
bTags = []
for i in soup.findAll('span'):
    bTags.append(i.text)
</code></pre>

<p>I am not sure how can I get only the italic text.</p>

<p>Try this:</p>

<pre><code>from bs4 import BeautifulSoup

soup = BeautifulSoup(html)
bTags = []
for i in soup.find_all('span', style=lambda x: x and 'Italic' in x):
    bTags.append(i.text)

print bTags
</code></pre>

<p>Passing a function to the <code>style</code> argument will filter results by the result of that function, with its input as the value of the <code>style</code> attribute. We check to see if the string <code>Italic</code> is inside the attribute, and if so, return True.</p>

<p>You may need a more sophisticated algorithm depending on the rest of what your HTML looks like.</p>

python html italic