Import BeautifulSoup from BeautifulSoup;
Fobj = open(“my.html”);
Data = fobj.read();
Fobj.close();
Soup = BeautifulSoup(data);
Trlist = soup.findAll(“tr”);
Rownum = len(trlist);
Colnum = len(trlist[0]);
Trlist[0].insert(colnum, “hahaha ”);
Tdlist = trlist[0].findAll(“td”);
Content= tdlist[0].renderContents();
Fobj = file(“my.html”, “w”);
Fobj.write(str(soup));
Fobj.close();
用正则表达式或者解析HTML的库修改
python不是做这事的吧?