Last active
July 15, 2024 15:24
-
-
Save starkxun/ebd9438d026da3219ae30aa3c05bcf1f to your computer and use it in GitHub Desktop.
解析提取buildwith网站的apex域名
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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