This file has been truncated, but you can view the full file.
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
| . | |
| .. | |
| ........ | |
| @ | |
| * | |
| *.* | |
| *.*.* | |
| 🎠|
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") |
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 html.parser import HTMLParser | |
| import re | |
| class MyHTMLParser(HTMLParser): | |
| def __init__(self): | |
| super().__init__() | |
| self.in_tr = False | |
| self.td_count = 0 | |
| self.fifth_td_content = None |