Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hunter.io find email #2558

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 30 additions & 34 deletions Hunter.io/Hunter.io_Find_email.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"tags": []
},
"source": [
"<img width=\"8%\" alt=\"Naas\" src=\"https://raw.githubusercontent.com/jupyter-naas/awesome-notebooks/master/.github/assets/logos/Naas.png\" style=\"border-radius: 15%\">"
"<img width=\"8%\" alt=\"GitHub.png\" src=\"https://cdn.prod.website-files.com/655b8092803c160e897db87b/655b8092803c160e897dc450_hunter_logo.webp\" style=\"border-radius: 15%\">"
]
},
{
Expand All @@ -20,7 +20,7 @@
},
"source": [
"# Hunter.io - Find email\n",
"<a href=\"https://bit.ly/3JyWIk6\">Give Feedback</a> | <a href=\"https://github.com/jupyter-naas/awesome-notebooks/issues/new?assignees=&labels=bug&template=bug_report.md&title=Hunter.io+-+Find+email:+Error+short+description\">Bug report</a>"
"<a href=\"https://bit.ly/3JyWIk6\">Give Feedback</a> | <a href=\"https://github.com/jupyter-naas/awesome-notebooks/issues/new?assignees=&labels=bug&template=bug_report.md&title=GitHub+-+Add+new+issues+as+page+in+Notion+database:+Error+short+description\">Bug report</a>"
]
},
{
Expand Down Expand Up @@ -93,7 +93,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "353ef79c",
"metadata": {
"papermill": {},
Expand All @@ -119,18 +119,15 @@
{
"cell_type": "markdown",
"id": "b69f38ae-a69c-4360-8cf9-099cda04f098",
"metadata": {
"papermill": {},
"tags": []
},
"metadata": {},
"source": [
"- `domain_name`: company name\n",
"- `api_key`: token to get data through hunter.io"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "01647a55",
"metadata": {
"papermill": {},
Expand All @@ -139,7 +136,9 @@
"outputs": [],
"source": [
"domain_name = \"naas.ai\"\n",
"api_key = \"899fa50c3a6c56e8b19e37608140f327bf9xxxxx\""
"api_key = \"899fa50c3a6c56e8b19e37608140f327bf9xxxxx\"\n",
"first_name = \"florent\"\n",
"last_name = \"ravenel\""
]
},
{
Expand All @@ -156,20 +155,16 @@
{
"cell_type": "markdown",
"id": "ebfad846-2a68-4855-909c-1b2a9a7bcfa5",
"metadata": {
"papermill": {},
"tags": []
},
"metadata": {},
"source": [
"### Save to pickle"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "187ace2f-4049-4e55-b856-a955add1bfd4",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
Expand All @@ -183,44 +178,41 @@
{
"cell_type": "markdown",
"id": "7537ee02-afad-4d87-8883-afae67365f46",
"metadata": {
"papermill": {},
"tags": []
},
"metadata": {},
"source": [
"### Find emails"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "bb42b49d-b53e-4255-8a59-c824cd49aeac",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"def domain_search(domain, api_key):\n",
" url = f\"https://api.hunter.io/v2/domain-search?domain={domain}&api_key={api_key}\"\n",
" url = f\"https://api.hunter.io/v2/email-finder?domain=reddit.com&first_name={first_name}&last_name={last_name}n&api_key={api_key}\"\n",
" response = requests.get(url)\n",
"\n",
" \n",
" if response.status_code == 200:\n",
" data = response.json()\n",
" emails = []\n",
"\n",
" # Extract emails from the response\n",
" if 'data' in data:\n",
" for email in data['data']['emails']:\n",
" emails.append(email['value'])\n",
" emails.append(data['data']['email'])\n",
" \n",
" # Save emails to pickle file\n",
" save_to_pickle(emails, f\"{domain}_emails.pickle\")\n",
" return emails\n",
" else:\n",
" return {\"error\": \"No data found\"}\n",
" else:\n",
" return {\"error\": f\"Error {response.status_code}: {response.json().get('errors', 'Unknown error')}\"}"
" return {\"error\": f\"Error {response.status_code}: {response.json().get('errors', 'Unknown error')}\"}\n",
" "
]
},
{
Expand All @@ -237,27 +229,31 @@
{
"cell_type": "markdown",
"id": "8b6ecf57-fec4-4e72-a7b8-4985bca76c05",
"metadata": {
"papermill": {},
"tags": []
},
"metadata": {},
"source": [
"### Display result"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "5182d09a-e6d7-4d9d-9f38-eb3a9ce87cf1",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"domain_search_result = domain_search(domain_name, api_key)\n",
"domain_search_result"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6a1d5634-fe3b-4fbd-aef7-b258c20a8d25",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -279,8 +275,8 @@
"version": "3.9.6"
},
"naas": {
"notebook_id": "29b357b7e5487a12133180f7f41dd8b330732ea9d4f1c3892eaae3f389bffd75",
"notebook_path": "Hunter.io/Hunter.io_Find_email.ipynb"
"notebook_id": "b8a92a0e4b6e40db304564f999566443fb35e93df716ab4be5021aabba8230ee",
"notebook_path": "GitHub/GitHub_Add_new_issues_as_page_in_Notion_database.ipynb"
},
"papermill": {
"default_parameters": {},
Expand All @@ -291,4 +287,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
Loading