Last active
December 12, 2017 17:27
-
-
Save 0xbadjuju/6d69e4e32a77905415f0141758f749bb to your computer and use it in GitHub Desktop.
Get-Emails
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
Function Get-EmailsHunter() | |
{ | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory=$True, HelpMessage="Domain to harvest.")] | |
[String]$Domain, | |
[Parameter(Mandatory=$True, HelpMessage="https://hunter.io/api_keys")] | |
[string]$ApiKey | |
) | |
$offset=0; | |
while ($true) { | |
$webrequest = Invoke-WebRequest -Uri "https://api.hunter.io/v2/domain-search?domain=$domain&limit=100&offset=$offset&api_key=$ApiKey"; | |
if ($webrequest.StatusCode -ne 200) | |
{ | |
return; | |
} | |
$json = ConvertFrom-Json -InputObject $webrequest; | |
$emails = [string[]]$json.data.emails.value; | |
$emails | %{ $_ | Tee-Object -Append -FilePath "$($domain)_hunter_emails.txt" }; | |
if ($emails.Count -lt 100) | |
{ | |
return; | |
} | |
$offset += 100; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment