Forked from brevityinmotion/brevity-process-httpx.py
Created
October 1, 2026 14:09
-
-
Save thimslugga/b93a0f8a50b45f4563655e50ddba6a47 to your computer and use it in GitHub Desktop.
Function to parse and process output from HTTPX
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
| def processHTTPXCrawl(programName, rawBucketPath, refinedBucketPath, inputBucketPath, presentationBucketPath): | |
| filePath = refinedBucketPath + programName + '/' + programName + '-httpx-crawl.json' | |
| df = pd.read_json(filePath, lines=True) | |
| df['program'] = programName | |
| from urllib.parse import urlparse | |
| def _parseUrlRoot(urlvalue): | |
| cleanurl = urlparse(urlvalue).netloc | |
| return cleanurl | |
| def _parseUrlBase(urlvalue): | |
| baseurl = urlparse(urlvalue)#.netloc | |
| baseurl = baseurl.scheme + '://' + baseurl.netloc + baseurl.path | |
| return baseurl | |
| df['domain'] = df['url'].apply(_parseUrlRoot) | |
| df['baseurl'] = df['url'].apply(_parseUrlBase) | |
| storePath = presentationBucketPath + 'urls/' + programName + '-httpx-crawl.csv' | |
| df.to_csv(storePath, index=False, columns=['program','domain','baseurl','url','content-type','content-length','status-code']) | |
| storePathUrl = inputBucketPath + programName + '/' + programName + '-urls-crawl.csv' | |
| df['url'].to_csv(storePathUrl, header=False, index=False, sep='\n') | |
| return df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment