Skip to content

Commit d08e4c4

Browse files
authored
Update getproxy.py
1 parent 713a1d5 commit d08e4c4

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

getproxy.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
1-
import subprocess
21
import os
32
import requests
43
from git import Repo
54
import time
65

7-
repo_path = '/root/grasspr/' # Path to the Git repository
86

9-
while True:
10-
# Download the file from the URL
11-
url = 'https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/all.txt'
12-
response = requests.get(url)
13-
with open('all.txt', 'wb') as f:
14-
f.write(response.content)
7+
# Download the file from the URL
8+
url = 'https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/all.txt'
9+
response = requests.get(url)
10+
with open('all.txt', 'wb') as f:
11+
f.write(response.content)
1512

16-
# Rename the file
17-
os.rename('all.txt', 'proxy.txt')
13+
# Rename the file
14+
os.rename('all.txt', 'proxy.txt')
1815

19-
# Add all files to the Git repository
20-
repo = Repo(repo_path)
21-
repo.index.add('*')
16+
# Initialize the Git repository in the current directory
17+
repo = Repo('.')
18+
repo.index.add(['proxy.txt'])
2219

23-
# Commit changes
24-
repo.index.commit('Automatic commit')
20+
# Commit changes
21+
repo.index.commit('Automatic commit')
2522

26-
# Push changes to the 'main' branch of the remote repository
27-
origin = repo.remote(name='origin')
28-
origin.push('main')
29-
30-
# Wait for 5 minutes before running the loop again
31-
time.sleep(5 * 60)
23+
# Push changes to the 'main' branch of the remote repository
24+
origin = repo.remote(name='origin')
25+
origin.push('main')
3226

27+

0 commit comments

Comments
 (0)