-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Text tools added, testing in progress
- Loading branch information
Showing
7 changed files
with
130 additions
and
9 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from Lib.net_utils import download_wet_file" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"sample_url = 'https://data.commoncrawl.org/crawl-data/CC-MAIN-2022-05/segments/1642320299852.23/wet/CC-MAIN-20220116093137-20220116123137-00000.warc.wet.gz'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "ResponseException", | ||
"evalue": "Response failed with message REQUEST FOR https://data.commoncrawl.org/crawl-data/CC-MAIN-2022-05/segments/1642320299852.23/wet/CC-MAIN-20220116093137-20220116123137-00000.warc.wet.gz FAILED WITH CODE 503, MEANING Service Unavailable", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[1;31mResponseException\u001b[0m Traceback (most recent call last)", | ||
"Cell \u001b[1;32mIn[3], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m text \u001b[39m=\u001b[39m download_wet_file(sample_url, should_capture\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m, should_split\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m)\n", | ||
"File \u001b[1;32mc:\\Users\\George\\Documents\\Programming\\local_installs\\CommonCrawler\\Lib\\net_utils.py:78\u001b[0m, in \u001b[0;36mdownload_wet_file\u001b[1;34m(path, standard_encoding, error_handling, save_file_path, unzipped_path, should_split, should_capture, should_print)\u001b[0m\n\u001b[0;32m 57\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mdownload_wet_file\u001b[39m(path:\u001b[39mstr\u001b[39m, standard_encoding:\u001b[39mstr\u001b[39m \u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39mutf-8\u001b[39m\u001b[39m'\u001b[39m, error_handling:\u001b[39mstr\u001b[39m \u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39mignore\u001b[39m\u001b[39m'\u001b[39m, \n\u001b[0;32m 58\u001b[0m save_file_path:\u001b[39mstr\u001b[39m \u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39mNONAME.warc.wet.gz\u001b[39m\u001b[39m'\u001b[39m, unzipped_path:\u001b[39mstr\u001b[39m \u001b[39m=\u001b[39m \u001b[39m'\u001b[39m\u001b[39mUNZIPPED.warc\u001b[39m\u001b[39m'\u001b[39m,\n\u001b[0;32m 59\u001b[0m should_split:\u001b[39mbool\u001b[39m \u001b[39m=\u001b[39m\u001b[39mFalse\u001b[39;00m, should_capture:\u001b[39mbool\u001b[39m \u001b[39m=\u001b[39m\u001b[39mFalse\u001b[39;00m, should_print:\u001b[39mbool\u001b[39m \u001b[39m=\u001b[39m\u001b[39mFalse\u001b[39;00m) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m \u001b[39mstr\u001b[39m:\n\u001b[0;32m 60\u001b[0m \u001b[39m \u001b[39m\u001b[39m'''\u001b[39;00m\n\u001b[0;32m 61\u001b[0m \u001b[39m This function pulls down the .wet gz file with the given filepath. The filepath \u001b[39;00m\n\u001b[0;32m 62\u001b[0m \u001b[39m provided **must** be a valid path to a common crawl .wet file.\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 75\u001b[0m \u001b[39m @return: Returns a cleaned string.\u001b[39;00m\n\u001b[0;32m 76\u001b[0m \u001b[39m '''\u001b[39;00m\n\u001b[1;32m---> 78\u001b[0m download_file(path\u001b[39m=\u001b[39;49mpath, save_file_path\u001b[39m=\u001b[39;49msave_file_path, unzipped_path\u001b[39m=\u001b[39;49munzipped_path, should_print\u001b[39m=\u001b[39;49mshould_print)\n\u001b[0;32m 80\u001b[0m \u001b[39m# Written to disk, now get raw text.\u001b[39;00m\n\u001b[0;32m 81\u001b[0m text \u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39m\"\u001b[39m\n", | ||
"File \u001b[1;32mc:\\Users\\George\\Documents\\Programming\\local_installs\\CommonCrawler\\Lib\\net_utils.py:39\u001b[0m, in \u001b[0;36mdownload_file\u001b[1;34m(path, save_file_path, unzipped_path, should_print)\u001b[0m\n\u001b[0;32m 37\u001b[0m r \u001b[39m=\u001b[39m requests\u001b[39m.\u001b[39mget(path, stream\u001b[39m=\u001b[39m\u001b[39mTrue\u001b[39;00m)\n\u001b[0;32m 38\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m r\u001b[39m.\u001b[39mok:\n\u001b[1;32m---> 39\u001b[0m \u001b[39mraise\u001b[39;00m ResponseException(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mREQUEST FOR \u001b[39m\u001b[39m{\u001b[39;00mpath\u001b[39m}\u001b[39;00m\u001b[39m FAILED WITH CODE \u001b[39m\u001b[39m{\u001b[39;00mr\u001b[39m.\u001b[39mstatus_code\u001b[39m}\u001b[39;00m\u001b[39m, MEANING \u001b[39m\u001b[39m{\u001b[39;00mr\u001b[39m.\u001b[39mreason\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m)\n\u001b[0;32m 41\u001b[0m \u001b[39m# Got file, now write it to disk.\u001b[39;00m\n\u001b[0;32m 42\u001b[0m total \u001b[39m=\u001b[39m \u001b[39mint\u001b[39m(r\u001b[39m.\u001b[39mheaders\u001b[39m.\u001b[39mget(\u001b[39m'\u001b[39m\u001b[39mcontent-length\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m0\u001b[39m))\n", | ||
"\u001b[1;31mResponseException\u001b[0m: Response failed with message REQUEST FOR https://data.commoncrawl.org/crawl-data/CC-MAIN-2022-05/segments/1642320299852.23/wet/CC-MAIN-20220116093137-20220116123137-00000.warc.wet.gz FAILED WITH CODE 503, MEANING Service Unavailable" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"text = download_wet_file(sample_url, should_capture=True, should_split=True)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.6" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |