-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (37 loc) · 1.07 KB
/
main.py
File metadata and controls
45 lines (37 loc) · 1.07 KB
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
36
37
38
39
40
41
42
43
44
45
import requests
import threading
import os
import time
link_url = "https://raw.githubusercontent.com/codingbox/Pixiv-Craw/main/url.txt"
os.system("curl -O " + link_url)
url_list = []
f = open("url.txt", "r")
line = f.readline()
while line:
url_list.append(line.rstrip('\n'))
line = f.readline()
url_list_ok = []
def request_url(n, k):
for i in range(0, len(url_list)):
if i % n != k:
continue
try:
r = requests.get(url_list[i])
print("pic " + url_list[i] + " " + (str)(r.status_code))
if (r.status_code == 200):
url_list_ok.append(url_list[i])
except:
print("Error " + url_list[i])
threads = []
for i in range(0, 10):
threads.append(threading.Thread(target = request_url, args=(10, i)))
for i in range(0, 10):
threads[i].start()
for i in range(0, 10):
threads[i].join()
with open("url_ok.txt", 'a') as f:
f.seek(0)
f.truncate()
for pic_url in url_list_ok:
f.write(pic_url + "\n")
os.remove("url.txt")