from bs4 import BeautifulSoup
# filename.html: https://pastebin.com/HZjkEf9s
with open('filename.html','r') as f:
string = f.read()
soup = BeautifulSoup(string, 'html.parser')
[s.extract() for s in soup('script') if 'a1=function()' in s.text] # может работать излишне, если есть другие script с функцией a1
with open('filename_0.html','w') as f:
f.write(str(soup))
# filename_0.html : https://pastebin.com/ck7AHsvE