Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- metadata/down_metadata.py +39 -0
- metadata/post.tar.gz +3 -0
- metadata/posts.json +3 -0
.gitattributes
CHANGED
@@ -53,3 +53,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
56 |
+
metadata/posts.json filter=lfs diff=lfs merge=lfs -text
|
metadata/down_metadata.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from curl_cffi import requests
|
2 |
+
import json
|
3 |
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
4 |
+
from tqdm.rich import tqdm
|
5 |
+
|
6 |
+
# 定义爬取函数
|
7 |
+
def fetch_url(page):
|
8 |
+
url = f"https://yande.re/post.json?limit=100&page={page}"
|
9 |
+
response = requests.get(url, impersonate="chrome110")
|
10 |
+
# 检查请求是否成功
|
11 |
+
if response.status_code == 200:
|
12 |
+
return response.json()
|
13 |
+
else:
|
14 |
+
print(f"Failed to retrieve data from {url}")
|
15 |
+
return None
|
16 |
+
|
17 |
+
# 定义保存为 JSON 的函数
|
18 |
+
def save_json(data, page,):
|
19 |
+
if data:
|
20 |
+
with open(f"jsonpart/page_{page}.json", 'w', encoding='utf-8') as f:
|
21 |
+
json.dump(data, f, ensure_ascii=False, indent=4)
|
22 |
+
|
23 |
+
# 使用 ThreadPoolExecutor 创建线程池来并发爬取
|
24 |
+
def main():
|
25 |
+
bar = tqdm(total=25000)
|
26 |
+
pages = range(25001) # 0 到 25000 页
|
27 |
+
# 设置线程池的最大线程数,例如此处设置为 20
|
28 |
+
with ThreadPoolExecutor(max_workers=20) as executor:
|
29 |
+
# 创建 future 到 URL 的映射
|
30 |
+
future_to_url = {executor.submit(fetch_url, page): page for page in pages}
|
31 |
+
# 等待线程完成
|
32 |
+
for future in as_completed(future_to_url):
|
33 |
+
page = future_to_url[future]
|
34 |
+
data = future.result()
|
35 |
+
save_json(data, page)
|
36 |
+
bar.update(1)
|
37 |
+
|
38 |
+
if __name__ == "__main__":
|
39 |
+
main()
|
metadata/post.tar.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3e5b70c44ac565fd418566fd900fa08a41aaa0e11cebb40b82021e6b5da00fce
|
3 |
+
size 194969266
|
metadata/posts.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6e622ca451d7f809dcc9b9c61d9f8c21e0128225b45c1b7b7a97490fa6e9a4ee
|
3 |
+
size 2110864845
|