Repository navigation
Feat/Download domains-top-1000.csv from s3 #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
handecelikkanat
wants to merge
13
commits into
master
Choose a base branch
from
feat/domains-top-1000-from-s3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cb39af3
feat: have get_stats.sh download domains-top-1000.csv from s3
handecelikkanat 0cef8b2
feat(domain.py): read domain statistics from downloaded s3 file
handecelikkanat 2fc1583
feat(domains.md): increase top-domains count to 1000 from 500.
handecelikkanat e73c449
feat(index.md): increase top-domains count to 1000 from 500.
handecelikkanat 3c9c1cd
fix(domain.py): readd save_data
handecelikkanat d4bfcfe
fix(get_stats.sh): update domains-top-1000-extended.csv, reflecting c…
handecelikkanat 61d211f
feat(domain.py,plot.sh): move calculation of percentages here from cr…
handecelikkanat 157d044
fix(domain.py,stats.sh): use 'extended' label for file
handecelikkanat 9551a3b
feat(get_stats.sh): streamline s3 paths so they can be overriden for …
handecelikkanat 5836eac
feat(get_stats.sh): make curl branch fail on unexisting top-domains f…
handecelikkanat e97a640
fix(domain.py): correct name collusion read_data -> read_top_domains
handecelikkanat 7521b9f
feat(get_stats.sh): download gzipped file. update bucket name placeho…
handecelikkanat 0fbc848
feat(domain.py): add gzip handling
handecelikkanat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,53 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Download crawl statistics and top-domains csv files into ./stats/ | ||
| # | ||
| # Usage: ./get_stats.sh | ||
| # Test: Override TOP_DOMAINS_S3/URL, eg. | ||
| # TOP_DOMAINS_S3=s3://test-bucket/test-prefix/crawl-analysis ./get_stats.sh | ||
|
|
||
|
|
||
| set -o pipefail | ||
|
|
||
| if aws s3 ls s3://commoncrawl/crawl-analysis/ | sed -E 's@.* @@; s@/$@@' >./stats/crawls.txt; then | ||
| TOP_DOMAINS_FILE=domains-top-1000-extended.csv.gz | ||
| TOP_DOMAINS_FOLDER=./stats/top-domains | ||
|
|
||
| CRAWL_ANALYSIS_S3=s3://commoncrawl/crawl-analysis | ||
| CRAWL_ANALYSIS_URL=https://data.commoncrawl.org/crawl-analysis | ||
|
|
||
| # Override to test, see above. | ||
| TOP_DOMAINS_S3=${TOP_DOMAINS_S3:-$CRAWL_ANALYSIS_S3} | ||
| TOP_DOMAINS_URL=${TOP_DOMAINS_URL:-$CRAWL_ANALYSIS_URL} | ||
|
|
||
|
|
||
| if aws s3 ls ${CRAWL_ANALYSIS_S3}/ | sed -E 's@.* @@; s@/$@@' >./stats/crawls.txt; then | ||
| ON_AWS=true; | ||
| echo "Running on AWS (AWS CLI configured for authenticated access)" | ||
| else | ||
| echo "Downloading from https://data.commoncrawl.org/ using curl" | ||
| echo "Downloading from ${CRAWL_ANALYSIS_URL} using curl" | ||
| # list of crawls enumerated in crawlstats.py | ||
| python3 -c 'from crawlstats import MonthlyCrawl; [print(c) for c in sorted(MonthlyCrawl.by_name.keys())]' >./stats/crawls.txt | ||
| ON_AWS=false | ||
| fi | ||
|
|
||
| mkdir -p ${TOP_DOMAINS_FOLDER} | ||
|
|
||
| while read crawl; do | ||
| echo $crawl | ||
| if [ -e stats/$crawl.gz ]; then | ||
| echo " ... exists" | ||
| continue | ||
| echo " ... stats exist" | ||
| elif $ON_AWS; then | ||
| aws s3 cp ${CRAWL_ANALYSIS_S3}/$crawl/stats/part-00000.gz ./stats/$crawl.gz | ||
| else | ||
| curl --silent ${CRAWL_ANALYSIS_URL}/$crawl/stats/part-00000.gz >./stats/$crawl.gz | ||
| fi | ||
| if $ON_AWS; then | ||
| aws s3 cp s3://commoncrawl/crawl-analysis/$crawl/stats/part-00000.gz ./stats/$crawl.gz | ||
| # top-domains csv might be missing for older crawls, in that case continue without failing | ||
| TOP_DOMAINS_TARGET=${TOP_DOMAINS_FOLDER}/${crawl}.${TOP_DOMAINS_FILE} | ||
| if [ -e ${TOP_DOMAINS_TARGET} ]; then | ||
| echo " ... top-domains exist" | ||
| elif $ON_AWS; then | ||
| aws s3 cp ${TOP_DOMAINS_S3}/$crawl/stats/${TOP_DOMAINS_FILE} ${TOP_DOMAINS_TARGET} | ||
| else | ||
| curl --silent https://data.commoncrawl.org/crawl-analysis/$crawl/stats/part-00000.gz >./stats/$crawl.gz | ||
| curl --silent --fail ${TOP_DOMAINS_URL}/$crawl/stats/${TOP_DOMAINS_FILE} -o ${TOP_DOMAINS_TARGET} || { rm -f ${TOP_DOMAINS_TARGET}; false; } | ||
| fi | ||
| done <./stats/crawls.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am leaving this file (repo-only) uncompressed, so its easier for the github.io users to open.