An open source, non-profit web search engine
Initial script to analyse links
Daoud Clarkeb6b175894e34
diff --git a/analyse/analyse_crawled_links.py b/analyse/analyse_crawled_links.pynew file mode 100644index 0000000..775aba8--- /dev/null+++ b/analyse/analyse_crawled_links.py@@ -0,0 +1,36 @@+import glob+import gzip+import json++import django+from django.conf import settings++django.setup()+++from mwmbl.crawler.batch import HashedBatch++CRAWL_GLOB = "./devdata/batches/**/*.json.gz"+++++def get_urls():+ for path in glob.glob(CRAWL_GLOB, recursive=True):+ data = json.load(gzip.open(path))+ batch = HashedBatch.parse_obj(data)+ user = batch.user_id_hash+ for item in batch.items:+ if item.content is not None:+ for url in item.content.links:+ yield user, url+++def run():+ for user, url in get_urls():+ print(user, url)++++if __name__ == "__main__":+ run()