View Single Post
Old 08-22-2017, 02:14 PM   #220
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,708
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
In formatImages() in cutils.py, you're souping a single line of xhtml that has an invalid closing div tag at the end of it. What did you think the parser would do with the extraneous closing tag?

Code:
soup = BeautifulSoup(line, 'html.parser')
where "line" is:

Code:
<img alt="" class="img065" src="../Images/lsh-23-065.png"/></div>
Will definitely drop the closing div.

This code:
Code:
line = str(soup)
commits the divless soup back to the xhtml.

You need to find a better way of isolating the img tag and writing the modified one(s) back without affecting the surrounding code.

The attached python script should make what's happening clear.
Attached Files
File Type: py testbs4.py (350 Bytes, 432 views)

Last edited by DiapDealer; 08-22-2017 at 02:17 PM.
DiapDealer is offline   Reply With Quote