Last active
May 14, 2022 20:29
-
-
Save streaak/d018931bf4d9861073790596ec8c27e0 to your computer and use it in GitHub Desktop.
Script to gather emails from Hunter.io API
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
#!/bin/bash | |
total=$(curl -s "https://api.hunter.io/v2/email-count?domain=$1" | jq -r '.data.total') | |
echo "Total is $total" | |
if [ "$total" != "0" ]; then | |
for (( i=0; i<=$total; i+=100 )) | |
do | |
echo "offset $i" | |
curl -s "https://api.hunter.io/v2/domain-search?domain=$1&api_key=KEYHERE&limit=100&offset=$i" | jq -r '.data.emails[].value' >> hunter_emails.txt | |
done | |
sort -uo hunter_emails.txt hunter_emails.txt | |
fi |
Yep, noticed that after I posted this. Running sort on every iteration is dumb anyway
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice. You can use sort outside of the for loop for better performance.