Neon-AI commited on
Commit
3180e55
·
verified ·
1 Parent(s): a63298a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import httpx
2
+ import gzip
3
+ import os
4
+
5
+ os.makedirs("/data", exist_ok=True)
6
+
7
+ url = "https://data.commoncrawl.org/crawl-001/cc-index.paths.gz"
8
+
9
+ print("Downloading...")
10
+ with httpx.stream("GET", url) as r:
11
+ with open("/data/cc-index.paths.gz", "wb") as f:
12
+ for chunk in r.iter_bytes():
13
+ f.write(chunk)
14
+
15
+ print("Unzipping...")
16
+ with gzip.open("/data/cc-index.paths.gz", "rb") as gz:
17
+ content = gz.read()
18
+ with open("/data/cc-index.paths.txt", "wb") as f:
19
+ f.write(content)
20
+
21
+ # Peek at first 20 lines
22
+ lines = content.decode("utf-8", errors="ignore").splitlines()
23
+ for line in lines[:20]:
24
+ print(line)