Skip to content

Instantly share code, notes, and snippets.

@starkxun
Last active July 15, 2024 15:24
Show Gist options
  • Select an option

  • Save starkxun/ebd9438d026da3219ae30aa3c05bcf1f to your computer and use it in GitHub Desktop.

Select an option

Save starkxun/ebd9438d026da3219ae30aa3c05bcf1f to your computer and use it in GitHub Desktop.
解析提取buildwith网站的apex域名
from bs4 import BeautifulSoup
# 设置输出文件路径
output_file = "output.txt"
with open("temp.html", "r", encoding='utf8') as f, open(output_file, "w", encoding='utf-8') as outfile: # 指定编码方式为 GBK
soup = BeautifulSoup(f, 'lxml')
for a_tag in soup.select('tr > td:nth-of-type(2) > a'):
outfile.write(a_tag.text + "\n")
print(f"提取结果已保存到 {output_file}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment