Beautiful Soup is adding whitespaces between every character

Viewed 789

I'm running Beautiful Soup on some HTML documents. All I want is to extract the text without any tags.

from bs4 import BeautifulSoup

def aex_extract_text(html):
    soup = BeautifulSoup(html, 'lxml')
    text = soup.get_text()
    return text

My input is somewhat pathological in the number of redundant tags that it's got. But it is automatically generated HTML, so there shouldn't be any missing angles or anything of that nature. It's some Drupal system that creates the HTML. On almost all documents it runs fine, but on about 1/50 I'm getting the first few lines good and then whitespace between every character, and the tags aren't being removed.

Anyone know what causes this sort of breakdown? I can't see anything obvious. The fact that it's breaking out in the middle of a paragraph is confusing. I don't need perfect preservation of the text, so if I need to pull out a few characters I don't mind.

Example input:

[...]

</FONT></FONT></P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US 
CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3>The 2</FONT></FONT><SUP><FONT 
FACE=Century Gothic, serif><FONT SIZE=3>nd</FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>  Respondent was declared the duly 
elected Member of Parliament for the  Chilanga Constituency.</FONT></FONT></P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 
0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century 
Gothic, serif><FONT SIZE=3>The result was  unsuccessfully challenged, in the High Court, to have it declared  null and void on a number of allegations 
not relevant to this appeal  as it will be seen later in this judgment.</FONT></FONT></P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-
bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century 
Gothic, serif><FONT SIZE=3>It is also not in  dispute that the learned trial judge informed the parties of his  intention to call some witnesses 
after the defence had closed its  case. Five witnesses, in total, were called by the court and they  were designated as court witnesses.</FONT></FONT></P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 
0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3>This appeal is  premised on one ground of appeal 
which is attacking the learned trial  judge&rsquo;s jurisdiction to call witnesses on his own motion.

[...]

Example output:

[...]

The 2nd Respondent was declared the duly elected Member of Parliament for the Chilanga Constituency. The result was unsuccessfully challenged, in the High Court, to have it declared null and void on a number of allegations not relevant to this appeal as it will be seen later in this judgment. It is also not in dispute that the learned trial judge informed the parties of his intention to call some witnesses a f t e r t h e d e f e n c e h a d c l o s e d i t s c a s e . F i v e w i t n e s s e s , i n t o t a l , w e r e c a l l e d b y t h e c o u r t a n d t h e y w e r e d e s i g n a t e d a s c o u r t w i t n e s s e s . / F O N T > / F O N T > / P > P L A N G = e n - U S C L A S S = w e s t e r n A L I G N = J U S T I F Y S T Y L E = m a r g i n - b o t t o m : 0 c m ; l i n e - h e i g h t : 1 5 0 % > B R > / P > P L A N G = e n - U S C L A S S = w e s t e r n A L I G N = J U S T I F Y S T Y L E = m a r g i n - b o t t o m :

[...]

UPDATE:

here's the full input up to where it goes wrong:

<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN>  <HTML>  <HEAD>    <META HTTP-EQUIV=CONTENT-TYPE CONTENT=text/html; charset=windows-1252>      <TITLE></TITLE>     <META NAME=GENERATOR CONTENT=OpenOffice.org 3.3  (Win32)>   <META NAME=AUTHOR CONTENT=user>     <META NAME=CREATED CONTENT=20081007;9280000>    <META NAME=CHANGED CONTENT=20081007;9280000>    <STYLE TYPE=text/css>   <!--        @page { size: 21.59cm 27.94cm; margin-left: 2.54cm; margin-right: 2.54cm; margin-top: 1.27cm; margin-bottom: 2.54cm }       P { margin-bottom: 0.21cm; line-height: 115%; text-align: left }        P.western { font-family: Calibri, serif; font-size: 11pt; so-language: en-US }          P.cjk { font-family: Arial Unicode MS, sans-serif; so-language: en-US }         P.ctl { font-family: Calibri, serif; font-size: 11pt }      -->     </STYLE>  </HEAD>  <BODY LANG=en-ZA DIR=LTR STYLE=border: none; padding: 0cm>  <DIV TYPE=HEADER>    <P LANG=en-US ALIGN=CENTER STYLE=margin-bottom: 0cm; line-height: 0.18cm>    <SPAN STYLE=font-style: normal><SPAN STYLE=font-weight: normal>J   <SDFIELD TYPE=PAGE SUBTYPE=RANDOM FORMAT=ARABIC>26</SDFIELD></SPAN></SPAN></P>      <P LANG=en-US STYLE=margin-bottom: 1.17cm; line-height: 0.18cm><BR>     </P>  </DIV>  <P LANG=en-US CLASS=western ALIGN=RIGHT STYLE=margin-bottom: 0.35cm; line-height: 150%>                                <FONT FACE=Calibri, serif><FONT SIZE=2 STYLE=font-size: 11pt><SPAN LANG=en-US><SPAN STYLE=font-style: normal><SPAN STYLE=font-weight: normal>              (706)</SPAN></SPAN></SPAN></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>IN THE SUPREME  COURT OF ZAMBIA                           SCZ APPEAL NO.182 OF 2007  </B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0.35cm><A NAME=DDE_LINK></A>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>HOLDEN AT LUSAKA                                                       SCZ Judgment No.  31 OF 2008</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>(CIVIL  JURISDICTION)</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>IN THE MATTER OF:             THE ELECTORAL ACT NO.12 OF 2006 SECTION 93 OF THE </B></FONT></FONT>  </P>  <P LANG=en-US CLASS=western STYLE=margin-left: 3.81cm; text-indent: 1.27cm; margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>LAWS OF ZAMBIA</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-left: 5.08cm; text-indent: -5.08cm; margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>IN THE MATTER OF:       PARLIAMENTARY ELECTION FOR CHILANGA CONSTITUENCY HELD ON THE 28</B></FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>TH</B></FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>  SEPTEMBER, 2006</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>IN THE MATTER OF:        AN ELECTION PETITION </B></FONT></FONT>  </P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>BETWEEN:</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>       PRISCILLA  MWENYA KAMANGA         -      APPELLANT</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>         AND</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>        THE  ATTORNEY-GENERAL             -              1</B></FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>ST</B></FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>  RESPONDENT</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>      HON. NG&rsquo;ANDU  PETER MAGANDE     -      2</B></FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>ND</B></FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>  RESPONDENT</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>CORAM :  Sakala,  CJ.,Chirwa, Mumba, Chitengi and Mushabati; JJS.</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>On  25</B></FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>TH</B></FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>  June, 2006 and 19</B></FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>th</B></FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>  August, 2008</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>For  the Appellants :  Mr.B.C. Mutale, SC. and Mr L. Kalaluka of Ellis and  Company</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0cm; border-top: none; border-bottom: 1.50pt solid #00000a; border-left: none; border-right: none; padding-top: 0cm; padding-bottom: 0.04cm; padding-left: 0cm; padding-right: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>For the 1</B></FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>st</B></FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>  Respondent:  Mr M. Mukwasa &ndash; State Advocate</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>For  the 2</B></FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>nd</B></FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3><B>  Respondent: Mr S.C. Malama, SC. of Jaques and Partners</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><FONT SIZE=3>______________________________________________________________________________</FONT></FONT></P>  <P LANG=en-US CLASS=western ALIGN=CENTER STYLE=margin-bottom: 0cm; border-top: none; border-bottom: 1.50pt solid #00000a; border-left: none; border-right: none; padding-top: 0cm; padding-bottom: 0.04cm; padding-left: 0cm; padding-right: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=4><B>JUDGMENT</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>Mushabati, JS.,  delivered the judgment of the Court.</B></FONT></FONT></P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0.35cm><BR><BR>  </P>  <P LANG=en-US CLASS=western ALIGN=RIGHT STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>(707)</B></FONT></FONT></P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>Cases referred to:</B></FONT></FONT></P>  <OL>      <LI><P LANG=en-US ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>     <FONT FACE=Calibri, serif><FONT SIZE=2 STYLE=font-size: 11pt><SPAN LANG=en-US><SPAN STYLE=font-style: normal><SPAN STYLE=font-weight: normal>Double    Mwale Vs The People [1984] Z.R. 76</SPAN></SPAN></SPAN></FONT></FONT></P>  </OL>  <P LANG=en-US STYLE=margin-left: 1.27cm; margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><B>Simwanza  Vs The People [1985] Z.R.15</B></FONT></P>  <P LANG=en-US STYLE=margin-left: 1.27cm; margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><B>Jones  Vs National Coal Board [1957] 2. ALL  E.R. 155</B></FONT></P>  <P LANG=en-US STYLE=margin-left: 1.27cm; margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><B>Re  Enock and Zaretzky, Bock and Co. [1910] 1 K.B.327</B></FONT></P>  <P LANG=en-US STYLE=margin-left: 1.27cm; margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><B>Porter  Vs Magill [2002] 1 ALL E.R. 465</B></FONT></P>  <P LANG=en-US STYLE=margin-left: 1.27cm; margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><B>Fallow  Vs Calvert [1960] 2.Q.B. 201</B></FONT></P>  <P LANG=en-US STYLE=margin-left: 1.27cm; margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><B>Water  Welles Ltd Vs Jackson [1984] Z.R. 98</B></FONT></P>  <P LANG=en-US STYLE=margin-left: 1.27cm; margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><B>Zambia  Telecommunications Ltd Vs Celtel (Z) Ltd SCZ No. 90 of 2006  (unreported)</B></FONT></P>  <P LANG=en-US STYLE=margin-left: 1.27cm; margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><B>Mazoka  and others Vs Mwanawasa and others [2005] Z.R. 138</B></FONT></P>  <P LANG=en-US STYLE=margin-left: 1.27cm; margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><B>Thomas  Mumba and others Vs The People SCZ Appeal No. 92-95 (unreported) </B></FONT>  </P>  <P LANG=en-US STYLE=margin-left: 1.27cm; margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><B>Lewanika  and others Vs Chiluba [1998] Z.R. 79</B></FONT></P>  <P LANG=en-US STYLE=margin-left: 1.27cm; margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><B>Mabenga  Vs Wina [2003] Z.R. 110</B></FONT></P>  <P LANG=en-US ALIGN=JUSTIFY STYLE=margin-left: 1.27cm; margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>Legislation  referred to:</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><B>Criminal  Procedure Code, Cap. 87 &ndash; S.149</B></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><B>Electoral  Act, No.12 of 2006 &ndash; SS.102(3) and 103(1)(a) and (b)</B></FONT></P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>Other works  referred to:</B></FONT></FONT></P>  <P LANG=en-US CLASS=western STYLE=margin-bottom: 0.35cm><FONT FACE=Century Gothic, serif><B>Halsburys  Laws of England 4</B></FONT><SUP><FONT FACE=Century Gothic, serif><B>th</B></FONT></SUP><FONT FACE=Century Gothic, serif><B>  Edition Vol. 17 Page 195 Paragraph 281</B></FONT></P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3>This is an appeal  against the High Court judgment of 30</FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>th</FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>  July, 2007 dismissing the appellant&rsquo;s petition against the  election of the 2</FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>nd</FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>  Respondent as a Member of Parliament for the Chilanga Parliamentary  Constituency during the Presidential and Parliamentary General  Elections held on 28</FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>th</FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>  September, 2006, seeking to nullify the 2</FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>nd</FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>  Respondent&rsquo;s election on a number of malpractices as pleaded in  the petition.</FONT></FONT></P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western ALIGN=RIGHT STYLE=margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western ALIGN=RIGHT STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3><B>(708)</B></FONT></FONT></P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3>We wish to state that  in the court below, the petition was prosecuted by two Petitioners  but the 2</FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>nd</FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>  Petitioner, Capt. Cosmas Moono, is not a party to this appeal.  However, for clarity&rsquo;s sake we shall simply refer to the  appellant as the Petitioner and the 1</FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>st</FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>  and 2</FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>nd</FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>  Respondents as the 1</FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>st</FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>  and 2</FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>nd</FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>  Respondents respectively, the titles they held in the court below.</FONT></FONT></P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <BR>  </P>  <P LANG=en-US CLASS=western ALIGN=JUSTIFY STYLE=margin-bottom: 0cm; line-height: 150%>  <FONT FACE=Century Gothic, serif><FONT SIZE=3>The undisputed facts  of this case are that both the Petitioner and the 2</FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>nd</FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>  Respondent contested the Parliamentary General Elections held on 28</FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>th</FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>  September, 2006 in the Chilanga Constituency. The Petitioner stood on  the Patriotic Front (PF) ticket; while the 2</FONT></FONT><SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>nd</FONT></FONT></SUP><FONT FACE=Century Gothic, serif><FONT SIZE=3>  Respondent stood on the ticket of the Movement for Multiparty  Democracy (MMD).

UPDATE:

I've voted to close my own question. The answer (which works) is here: BeautifulSoup return unexpected extra spaces

1 Answers

Look - the input document is invalid HTML - because it has three close tags at beginning:

</FONT></FONT></P>

may be this is the reason. May be also parse and change <BR> to <BR/>

Related