I am getting the following error:
Traceback (most recent call last):File "2.py", line 22, in <module>i.string.replace_with(i.string.replace(u'\xa0', '-'))
AttributeError: 'NoneType' object has no attribute 'replace_with'
Some of the code
soup = bs4(open("test.html")) table = soup.find("table", {"color":"#fff"})for i in soup.find_all('small'):i.string.replace_with(i.string.replace(u'\xa0', '-')) <--Line 22
It was working yesterday, but I had to reinstall Mint on another VM and I can't get that to work again. How can I fix that?
EDIT: This is all the code:
from bs4 import BeautifulSoup as bs4soup = bs4(open("test.html")) table = soup.find("table", {"color":"#fff"})for i in soup.find_all('small'):i.string.replace_with(i.string.replace(u'\xa0', '-'))#print soup
f = open("new.html", "w")
f.write(str(table))
This is the table in test.html:
<table color="#fff">
<tr>
<td><small><small> </small></small></td>
</tr></table>