用正则筛选出不包含ahrefs的行
import re
pattern = r'^(?!.*ahrefs).*$'
text = '''
This line contains ahrefs
Another line without it
Yet another line with ahrefs
No ahrefs here
'''
lines = text.strip().split('\n')
for line in lines:
if re.match(pattern, line):
print(line)