To extract the content from document1.txt and save it to a new document2.txt with the IP:port and the class attribute, you can use a programming language like Python. Here's a simple Python example using regular expressions:
```python
import re
# Read the content from document1.txt
with open('document1.txt', 'r', encoding='utf-8') as file:
content = file.read()
# Use regular expression to find the relevant parts
pattern = r'<a title=".*?" onMouseOver="s\('.*?'\)" onMouseOut="d\()" class="(\w+)">(\d+\.\d+\.\d+\.\d+:\d+)</a>'
matches = re.findall(pattern, content)
# Write the results to document2.txt
with open('document2.txt', 'w', encoding='utf-8') as file:
for match in matches:
file.write(f"{match}----{match}\n")
```
This code uses regular expressions to find the IP:port pairs and their corresponding class attributes, then writes them to document2.txt. Make sure the Python script is in the same directory as document1.txt.
```python
import re
# Read the content from document1.txt
with open('document1.txt', 'r', encoding='utf-8') as file:
content = file.read()
# Use regular expression to find the relevant parts
pattern = r'<a title=".*?" onMouseOver="s\('.*?'\)" onMouseOut="d\()" class="(\w+)">(\d+\.\d+\.\d+\.\d+:\d+)</a>'
matches = re.findall(pattern, content)
# Write the results to document2.txt
with open('document2.txt', 'w', encoding='utf-8') as file:
for match in matches:
file.write(f"{match}----{match}\n")
```
This code uses regular expressions to find the IP:port pairs and their corresponding class attributes, then writes them to document2.txt. Make sure the Python script is in the same directory as document1.txt.
