-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathget_data.sh
More file actions
executable file
·30 lines (25 loc) · 878 Bytes
/
Copy pathget_data.sh
File metadata and controls
executable file
·30 lines (25 loc) · 878 Bytes
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
#!/usr/bin/env bash
CRAWL=CC-MAIN-2017-13
BASE_URL=https://commoncrawl.s3.amazonaws.com
LOCAL_SEGMENTS=4
FILE_TYPE=wet
local_file_index=input/test_${FILE_TYPE}.txt
s3_sample_file_index=input/test_s3_${FILE_TYPE}.txt
test -d input || mkdir input
! test -e $local_files || rm $local_file_index
! test -e $s3_sample_file_index || rm $s3_sample_file_index
listing=crawl-data/$CRAWL/$FILE_TYPE.paths.gz
mkdir -p crawl-data/$CRAWL/
cd crawl-data/$CRAWL/
wget --timestamping $BASE_URL/$listing
cd -
gzip -dc $listing | sed 's@^@s3://commoncrawl/@' \
>input/all_${FILE_TYPE}_$CRAWL.txt
for segment in $(gzip -dc $listing | head -$LOCAL_SEGMENTS ); do
mkdir -p $(dirname $segment)
cd $(dirname $segment)
wget --timestamping $BASE_URL/$segment
cd -
echo file:$PWD/$segment >> $local_file_index
echo s3://commoncrawl/$segment >> $s3_sample_file_index
done