img.py

 1#!/usr/bin/env python3
 2
 3from bs4 import BeautifulSoup
 4import sys
 5
 6with open(sys.argv[1]) as f:
 7    html = BeautifulSoup(f.read(), 'html.parser')
 8
 9
10for i in html.find_all('p'):
11    if len(i.find_all('img')) > 0:
12        i.unwrap()
13
14with open(sys.argv[1], 'w') as f:
15    f.write(str(html))