-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfor_local_uses(windows).py
35 lines (27 loc) · 1.04 KB
/
for_local_uses(windows).py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests
from bs4 import BeautifulSoup
import subprocess
def copy(text):
process = subprocess.Popen('clip', stdin=subprocess.PIPE, close_fds=True)
process.communicate(input=text.encode())
# URL of the web page you want to extract text from
url = 'https://github.com/tolinkshare/freenode'
# Send a GET request to the URL and fetch the HTML content
response = requests.get(url)
# Parse the HTML content using BeautifulSoup
soup = BeautifulSoup(response.content,'html.parser')
# Find all the text within HTML tags
text = soup.get_text()
# Find the nodes
start_phrase = "🚀免费v2rayN节点列表"
end_phrase = "相关工具教程:"
# Find the indices of the start and end phrases
start_index = text.find(start_phrase)
end_index = text.find(end_phrase)
# Extract the chunk of text between the phrases
if start_index != -1 and end_index != -1:
chunk = text[start_index + len(start_phrase):end_index].strip()
print(chunk)
copy(chunk)
else:
print("Start or end phrase not found in the text.")