Skip to content

Commit

Permalink
feat: Hunter.io findings
Browse files Browse the repository at this point in the history
  • Loading branch information
varshakumarr committed Jun 27, 2024
1 parent b9719a9 commit 4d4b0d7
Show file tree
Hide file tree
Showing 3 changed files with 1,214 additions and 0 deletions.
331 changes: 331 additions & 0 deletions Hunter.io/Hunter.io_Find_email.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,331 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "84cadd0c",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"<img width=\"8%\" alt=\"GitHub.png\" src=\"https://cdn.prod.website-files.com/655b8092803c160e897db87b/655b8092803c160e897dc450_hunter_logo.webp\" style=\"border-radius: 15%\">"
]
},
{
"cell_type": "markdown",
"id": "0d43ed38",
"metadata": {
"papermill": {},
"tags": []
},
"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=GitHub+-+Add+new+issues+as+page+in+Notion+database:+Error+short+description\">Bug report</a>"
]
},
{
"cell_type": "markdown",
"id": "d9313642",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Tags:** #github #email #find #automation #snippet"
]
},
{
"cell_type": "markdown",
"id": "8faf487c",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Author:** [Varsha Kumar](https://www.linkedin.com/in/varsha-kumar-590466305/)"
]
},
{
"cell_type": "markdown",
"id": "3dba1c73-548d-4008-82ad-fdb2cb376771",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Last update:** 2024-06-26 (Created: 2024-06-25)"
]
},
{
"cell_type": "markdown",
"id": "naas-description",
"metadata": {
"papermill": {},
"tags": [
"description"
]
},
"source": [
"**Description:** This notebook allows users to find an email through hunter.io."
]
},
{
"cell_type": "markdown",
"id": "7412988b",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Input"
]
},
{
"cell_type": "markdown",
"id": "b483a140",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Import libraries"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "353ef79c",
"metadata": {
"execution": {
"iopub.execute_input": "2024-06-26T06:51:07.687424Z",
"iopub.status.busy": "2024-06-26T06:51:07.686982Z",
"iopub.status.idle": "2024-06-26T06:51:07.820922Z",
"shell.execute_reply": "2024-06-26T06:51:07.820320Z",
"shell.execute_reply.started": "2024-06-26T06:51:07.687346Z"
},
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"import requests\n",
"import pickle"
]
},
{
"cell_type": "markdown",
"id": "68b48858",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Setup variables"
]
},
{
"cell_type": "markdown",
"id": "b69f38ae-a69c-4360-8cf9-099cda04f098",
"metadata": {},
"source": [
"- `domain_name`: company name\n",
"- `api_key`: token to get data through hunter.io"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "01647a55",
"metadata": {
"execution": {
"iopub.execute_input": "2024-06-26T06:51:07.823964Z",
"iopub.status.busy": "2024-06-26T06:51:07.823776Z",
"iopub.status.idle": "2024-06-26T06:51:07.845207Z",
"shell.execute_reply": "2024-06-26T06:51:07.844693Z",
"shell.execute_reply.started": "2024-06-26T06:51:07.823942Z"
},
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"domain_name = \"naas.ai\"\n",
"api_key = \"899fa50c3a6c56e8b19e37608140f327bf9xxxxx\""
]
},
{
"cell_type": "markdown",
"id": "93347abb",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Model\n"
]
},
{
"cell_type": "markdown",
"id": "ebfad846-2a68-4855-909c-1b2a9a7bcfa5",
"metadata": {},
"source": [
"### Save to pickle"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "187ace2f-4049-4e55-b856-a955add1bfd4",
"metadata": {
"execution": {
"iopub.execute_input": "2024-06-26T06:51:07.847589Z",
"iopub.status.busy": "2024-06-26T06:51:07.847422Z",
"iopub.status.idle": "2024-06-26T06:51:07.941121Z",
"shell.execute_reply": "2024-06-26T06:51:07.940546Z",
"shell.execute_reply.started": "2024-06-26T06:51:07.847571Z"
}
},
"outputs": [],
"source": [
"def save_to_pickle(data, filename):\n",
" with open(filename, 'wb') as file:\n",
" pickle.dump(data, file)\n",
" print(f\"Data saved to {filename}\")"
]
},
{
"cell_type": "markdown",
"id": "7537ee02-afad-4d87-8883-afae67365f46",
"metadata": {},
"source": [
"### Find emails"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "bb42b49d-b53e-4255-8a59-c824cd49aeac",
"metadata": {
"execution": {
"iopub.execute_input": "2024-06-26T06:52:03.944977Z",
"iopub.status.busy": "2024-06-26T06:52:03.944753Z",
"iopub.status.idle": "2024-06-26T06:52:03.951063Z",
"shell.execute_reply": "2024-06-26T06:52:03.950533Z",
"shell.execute_reply.started": "2024-06-26T06:52:03.944954Z"
},
"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",
" response = requests.get(url)\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",
" \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')}\"}"
]
},
{
"cell_type": "markdown",
"id": "b819d06a",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Output\n"
]
},
{
"cell_type": "markdown",
"id": "8b6ecf57-fec4-4e72-a7b8-4985bca76c05",
"metadata": {},
"source": [
"### Display result"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "5182d09a-e6d7-4d9d-9f38-eb3a9ce87cf1",
"metadata": {
"execution": {
"iopub.execute_input": "2024-06-26T06:52:05.312000Z",
"iopub.status.busy": "2024-06-26T06:52:05.311776Z",
"iopub.status.idle": "2024-06-26T06:52:05.442030Z",
"shell.execute_reply": "2024-06-26T06:52:05.441430Z",
"shell.execute_reply.started": "2024-06-26T06:52:05.311977Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data saved to naas.ai_emails.pickle\n"
]
},
{
"data": {
"text/plain": [
"['jeremy@naas.ai', 'abi@naas.ai', 'support@naas.ai']"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"domain_search_result = domain_search(domain_name, api_key)\n",
"domain_search_result"
]
}
],
"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.9.6"
},
"naas": {
"notebook_id": "b8a92a0e4b6e40db304564f999566443fb35e93df716ab4be5021aabba8230ee",
"notebook_path": "GitHub/GitHub_Add_new_issues_as_page_in_Notion_database.ipynb"
},
"papermill": {
"default_parameters": {},
"environment_variables": {},
"parameters": {},
"version": "2.3.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 4d4b0d7

Please sign in to comment.