Skip to content

Instantly share code, notes, and snippets.

@ammarhaiderak
Last active April 18, 2024 13:40
Show Gist options
  • Save ammarhaiderak/57fa4ab31932c7adf24dfe5183dd4d44 to your computer and use it in GitHub Desktop.
Save ammarhaiderak/57fa4ab31932c7adf24dfe5183dd4d44 to your computer and use it in GitHub Desktop.
Email Scrapper
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "EmailScrapper2.ipynb",
"provenance": [],
"collapsed_sections": [],
"toc_visible": true,
"authorship_tag": "ABX9TyMD9oj4GDynsrQIPwEKRp0o",
"include_colab_link": true
},
"kernelspec": {
"name": "python2",
"display_name": "Python 2"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/ammarhaiderak/57fa4ab31932c7adf24dfe5183dd4d44/emailscrapper2.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "1H3cXpF9sXBw",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"outputId": "782bbdf1-ab99-424e-a8ff-f08df81a6872"
},
"source": [
"!pip install scrapy"
],
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"text": [
"Collecting scrapy\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/3b/e4/69b87d7827abf03dea2ea984230d50f347b00a7a3897bc93f6ec3dafa494/Scrapy-1.8.0-py2.py3-none-any.whl (238kB)\n",
"\r\u001b[K |█▍ | 10kB 11.7MB/s eta 0:00:01\r\u001b[K |██▊ | 20kB 2.2MB/s eta 0:00:01\r\u001b[K |████▏ | 30kB 2.8MB/s eta 0:00:01\r\u001b[K |█████▌ | 40kB 2.1MB/s eta 0:00:01\r\u001b[K |██████▉ | 51kB 2.3MB/s eta 0:00:01\r\u001b[K |████████▎ | 61kB 2.8MB/s eta 0:00:01\r\u001b[K |█████████▋ | 71kB 3.1MB/s eta 0:00:01\r\u001b[K |███████████ | 81kB 3.3MB/s eta 0:00:01\r\u001b[K |████████████▍ | 92kB 3.7MB/s eta 0:00:01\r\u001b[K |█████████████▊ | 102kB 3.4MB/s eta 0:00:01\r\u001b[K |███████████████ | 112kB 3.4MB/s eta 0:00:01\r\u001b[K |████████████████▌ | 122kB 3.4MB/s eta 0:00:01\r\u001b[K |█████████████████▉ | 133kB 3.4MB/s eta 0:00:01\r\u001b[K |███████████████████▏ | 143kB 3.4MB/s eta 0:00:01\r\u001b[K |████████████████████▋ | 153kB 3.4MB/s eta 0:00:01\r\u001b[K |██████████████████████ | 163kB 3.4MB/s eta 0:00:01\r\u001b[K |███████████████████████▎ | 174kB 3.4MB/s eta 0:00:01\r\u001b[K |████████████████████████▊ | 184kB 3.4MB/s eta 0:00:01\r\u001b[K |██████████████████████████ | 194kB 3.4MB/s eta 0:00:01\r\u001b[K |███████████████████████████▍ | 204kB 3.4MB/s eta 0:00:01\r\u001b[K |████████████████████████████▉ | 215kB 3.4MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▏ | 225kB 3.4MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▌| 235kB 3.4MB/s eta 0:00:01\r\u001b[K |████████████████████████████████| 245kB 3.4MB/s \n",
"\u001b[?25hCollecting pyOpenSSL>=16.2.0\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/9e/de/f8342b68fa9e981d348039954657bdf681b2ab93de27443be51865ffa310/pyOpenSSL-19.1.0-py2.py3-none-any.whl (53kB)\n",
"\r\u001b[K |██████ | 10kB 28.8MB/s eta 0:00:01\r\u001b[K |████████████▏ | 20kB 27.0MB/s eta 0:00:01\r\u001b[K |██████████████████▎ | 30kB 31.6MB/s eta 0:00:01\r\u001b[K |████████████████████████▍ | 40kB 18.6MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▌ | 51kB 21.5MB/s eta 0:00:01\r\u001b[K |████████████████████████████████| 61kB 7.6MB/s \n",
"\u001b[?25hCollecting protego>=0.1.15\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/db/6e/bf6d5e4d7cf233b785719aaec2c38f027b9c2ed980a0015ec1a1cced4893/Protego-0.1.16.tar.gz (3.2MB)\n",
"\r\u001b[K | | 10kB 31.0MB/s eta 0:00:01\r\u001b[K |▏ | 20kB 16.4MB/s eta 0:00:01\r\u001b[K |▎ | 30kB 22.1MB/s eta 0:00:01\r\u001b[K |▍ | 40kB 19.2MB/s eta 0:00:01\r\u001b[K |▌ | 51kB 12.8MB/s eta 0:00:01\r\u001b[K |▋ | 61kB 14.9MB/s eta 0:00:01\r\u001b[K |▊ | 71kB 12.3MB/s eta 0:00:01\r\u001b[K |▉ | 81kB 12.1MB/s eta 0:00:01\r\u001b[K |█ | 92kB 13.3MB/s eta 0:00:01\r\u001b[K |█ | 102kB 10.3MB/s eta 0:00:01\r\u001b[K |█▏ | 112kB 10.3MB/s eta 0:00:01\r\u001b[K |█▎ | 122kB 10.3MB/s eta 0:00:01\r\u001b[K |█▎ | 133kB 10.3MB/s eta 0:00:01\r\u001b[K |█▍ | 143kB 10.3MB/s eta 0:00:01\r\u001b[K |█▌ | 153kB 10.3MB/s eta 0:00:01\r\u001b[K |█▋ | 163kB 10.3MB/s eta 0:00:01\r\u001b[K |█▊ | 174kB 10.3MB/s eta 0:00:01\r\u001b[K |█▉ | 184kB 10.3MB/s eta 0:00:01\r\u001b[K |██ | 194kB 10.3MB/s eta 0:00:01\r\u001b[K |██ | 204kB 10.3MB/s eta 0:00:01\r\u001b[K |██▏ | 215kB 10.3MB/s eta 0:00:01\r\u001b[K |██▎ | 225kB 10.3MB/s eta 0:00:01\r\u001b[K |██▍ | 235kB 10.3MB/s eta 0:00:01\r\u001b[K |██▌ | 245kB 10.3MB/s eta 0:00:01\r\u001b[K |██▌ | 256kB 10.3MB/s eta 0:00:01\r\u001b[K |██▋ | 266kB 10.3MB/s eta 0:00:01\r\u001b[K |██▊ | 276kB 10.3MB/s eta 0:00:01\r\u001b[K |██▉ | 286kB 10.3MB/s eta 0:00:01\r\u001b[K |███ | 296kB 10.3MB/s eta 0:00:01\r\u001b[K |███ | 307kB 10.3MB/s eta 0:00:01\r\u001b[K |███▏ | 317kB 10.3MB/s eta 0:00:01\r\u001b[K |███▎ | 327kB 10.3MB/s eta 0:00:01\r\u001b[K |███▍ | 337kB 10.3MB/s eta 0:00:01\r\u001b[K |███▌ | 348kB 10.3MB/s eta 0:00:01\r\u001b[K |███▋ | 358kB 10.3MB/s eta 0:00:01\r\u001b[K |███▊ | 368kB 10.3MB/s eta 0:00:01\r\u001b[K |███▊ | 378kB 10.3MB/s eta 0:00:01\r\u001b[K |███▉ | 389kB 10.3MB/s eta 0:00:01\r\u001b[K |████ | 399kB 10.3MB/s eta 0:00:01\r\u001b[K |████ | 409kB 10.3MB/s eta 0:00:01\r\u001b[K |████▏ | 419kB 10.3MB/s eta 0:00:01\r\u001b[K |████▎ | 430kB 10.3MB/s eta 0:00:01\r\u001b[K |████▍ | 440kB 10.3MB/s eta 0:00:01\r\u001b[K |████▌ | 450kB 10.3MB/s eta 0:00:01\r\u001b[K |████▋ | 460kB 10.3MB/s eta 0:00:01\r\u001b[K |████▊ | 471kB 10.3MB/s eta 0:00:01\r\u001b[K |████▉ | 481kB 10.3MB/s eta 0:00:01\r\u001b[K |█████ | 491kB 10.3MB/s eta 0:00:01\r\u001b[K |█████ | 501kB 10.3MB/s eta 0:00:01\r\u001b[K |█████ | 512kB 10.3MB/s eta 0:00:01\r\u001b[K |█████▏ | 522kB 10.3MB/s eta 0:00:01\r\u001b[K |█████▎ | 532kB 10.3MB/s eta 0:00:01\r\u001b[K |█████▍ | 542kB 10.3MB/s eta 0:00:01\r\u001b[K |█████▌ | 552kB 10.3MB/s eta 0:00:01\r\u001b[K |█████▋ | 563kB 10.3MB/s eta 0:00:01\r\u001b[K |█████▊ | 573kB 10.3MB/s eta 0:00:01\r\u001b[K |█████▉ | 583kB 10.3MB/s eta 0:00:01\r\u001b[K |██████ | 593kB 10.3MB/s eta 0:00:01\r\u001b[K |██████ | 604kB 10.3MB/s eta 0:00:01\r\u001b[K |██████▏ | 614kB 10.3MB/s eta 0:00:01\r\u001b[K |██████▎ | 624kB 10.3MB/s eta 0:00:01\r\u001b[K |██████▎ | 634kB 10.3MB/s eta 0:00:01\r\u001b[K |██████▍ | 645kB 10.3MB/s eta 0:00:01\r\u001b[K |██████▌ | 655kB 10.3MB/s eta 0:00:01\r\u001b[K |██████▋ | 665kB 10.3MB/s eta 0:00:01\r\u001b[K |██████▊ | 675kB 10.3MB/s eta 0:00:01\r\u001b[K |██████▉ | 686kB 10.3MB/s eta 0:00:01\r\u001b[K |███████ | 696kB 10.3MB/s eta 0:00:01\r\u001b[K |███████ | 706kB 10.3MB/s eta 0:00:01\r\u001b[K |███████▏ | 716kB 10.3MB/s eta 0:00:01\r\u001b[K |███████▎ | 727kB 10.3MB/s eta 0:00:01\r\u001b[K |███████▍ | 737kB 10.3MB/s eta 0:00:01\r\u001b[K |███████▌ | 747kB 10.3MB/s eta 0:00:01\r\u001b[K |███████▌ | 757kB 10.3MB/s eta 0:00:01\r\u001b[K |███████▋ | 768kB 10.3MB/s eta 0:00:01\r\u001b[K |███████▊ | 778kB 10.3MB/s eta 0:00:01\r\u001b[K |███████▉ | 788kB 10.3MB/s eta 0:00:01\r\u001b[K |████████ | 798kB 10.3MB/s eta 0:00:01\r\u001b[K |████████ | 808kB 10.3MB/s eta 0:00:01\r\u001b[K |████████▏ | 819kB 10.3MB/s eta 0:00:01\r\u001b[K |████████▎ | 829kB 10.3MB/s eta 0:00:01\r\u001b[K |████████▍ | 839kB 10.3MB/s eta 0:00:01\r\u001b[K |████████▌ | 849kB 10.3MB/s eta 0:00:01\r\u001b[K |████████▋ | 860kB 10.3MB/s eta 0:00:01\r\u001b[K |████████▊ | 870kB 10.3MB/s eta 0:00:01\r\u001b[K |████████▊ | 880kB 10.3MB/s eta 0:00:01\r\u001b[K |████████▉ | 890kB 10.3MB/s eta 0:00:01\r\u001b[K |█████████ | 901kB 10.3MB/s eta 0:00:01\r\u001b[K |█████████ | 911kB 10.3MB/s eta 0:00:01\r\u001b[K |█████████▏ | 921kB 10.3MB/s eta 0:00:01\r\u001b[K |█████████▎ | 931kB 10.3MB/s eta 0:00:01\r\u001b[K |█████████▍ | 942kB 10.3MB/s eta 0:00:01\r\u001b[K |█████████▌ | 952kB 10.3MB/s eta 0:00:01\r\u001b[K |█████████▋ | 962kB 10.3MB/s eta 0:00:01\r\u001b[K |█████████▊ | 972kB 10.3MB/s eta 0:00:01\r\u001b[K |█████████▉ | 983kB 10.3MB/s eta 0:00:01\r\u001b[K |██████████ | 993kB 10.3MB/s eta 0:00:01\r\u001b[K |██████████ | 1.0MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████ | 1.0MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████▏ | 1.0MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████▎ | 1.0MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████▍ | 1.0MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████▌ | 1.1MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████▋ | 1.1MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████▊ | 1.1MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████▉ | 1.1MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████ | 1.1MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████ | 1.1MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████▏ | 1.1MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████▎ | 1.1MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████▎ | 1.1MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████▍ | 1.1MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████▌ | 1.2MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████▋ | 1.2MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████▊ | 1.2MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████▉ | 1.2MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████ | 1.2MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████ | 1.2MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████▏ | 1.2MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████▎ | 1.2MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████▍ | 1.2MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████▌ | 1.2MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████▌ | 1.3MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████▋ | 1.3MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████▊ | 1.3MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████▉ | 1.3MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████ | 1.3MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████ | 1.3MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████▏ | 1.3MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████▎ | 1.3MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████▍ | 1.3MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████▌ | 1.4MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████▋ | 1.4MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████▊ | 1.4MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████▊ | 1.4MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████▉ | 1.4MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████ | 1.4MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████ | 1.4MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████▏ | 1.4MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████▎ | 1.4MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████▍ | 1.4MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████▌ | 1.5MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████▋ | 1.5MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████▊ | 1.5MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████▉ | 1.5MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████ | 1.5MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████ | 1.5MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████ | 1.5MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████▏ | 1.5MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████▎ | 1.5MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████▍ | 1.5MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████▌ | 1.6MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████▋ | 1.6MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████▊ | 1.6MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████▉ | 1.6MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████ | 1.6MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████ | 1.6MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████▏ | 1.6MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████▎ | 1.6MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████▎ | 1.6MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████▍ | 1.6MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████▌ | 1.7MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████▋ | 1.7MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████▊ | 1.7MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████▉ | 1.7MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████ | 1.7MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████ | 1.7MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████▏ | 1.7MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████▎ | 1.7MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████▍ | 1.7MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████▌ | 1.8MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████▌ | 1.8MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████▋ | 1.8MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████▊ | 1.8MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████▉ | 1.8MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████ | 1.8MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████ | 1.8MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████▏ | 1.8MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████▎ | 1.8MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████▍ | 1.8MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████▌ | 1.9MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████▋ | 1.9MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████▊ | 1.9MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████▊ | 1.9MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████▉ | 1.9MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████ | 1.9MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████ | 1.9MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████▏ | 1.9MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████▎ | 1.9MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████▍ | 1.9MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████▌ | 2.0MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████▋ | 2.0MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████▊ | 2.0MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████▉ | 2.0MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████ | 2.0MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████ | 2.0MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████ | 2.0MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████▏ | 2.0MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████▎ | 2.0MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████▍ | 2.0MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████▌ | 2.1MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████▋ | 2.1MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████▊ | 2.1MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████▉ | 2.1MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████ | 2.1MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████ | 2.1MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████▏ | 2.1MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████▎ | 2.1MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████▎ | 2.1MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████▍ | 2.2MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████▌ | 2.2MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████▋ | 2.2MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████▊ | 2.2MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████▉ | 2.2MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████ | 2.2MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████ | 2.2MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████▏ | 2.2MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████▎ | 2.2MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████▍ | 2.2MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████▌ | 2.3MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████▌ | 2.3MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████▋ | 2.3MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████▊ | 2.3MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████▉ | 2.3MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████ | 2.3MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████ | 2.3MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████▏ | 2.3MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████▎ | 2.3MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████▍ | 2.3MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████▌ | 2.4MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████▋ | 2.4MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████▊ | 2.4MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████▊ | 2.4MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████▉ | 2.4MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████ | 2.4MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████ | 2.4MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████▏ | 2.4MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████▎ | 2.4MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████▍ | 2.4MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████▌ | 2.5MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████▋ | 2.5MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████▊ | 2.5MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████▉ | 2.5MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████ | 2.5MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████ | 2.5MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████ | 2.5MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████▏ | 2.5MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████▎ | 2.5MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████▍ | 2.5MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████▌ | 2.6MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████▋ | 2.6MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████▊ | 2.6MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████▉ | 2.6MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████ | 2.6MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████ | 2.6MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████▏ | 2.6MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████▎ | 2.6MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████▎ | 2.6MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████▍ | 2.7MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████▌ | 2.7MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████▋ | 2.7MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████▊ | 2.7MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████▉ | 2.7MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████ | 2.7MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████ | 2.7MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████▏ | 2.7MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████▎ | 2.7MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████▍ | 2.7MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████▌ | 2.8MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████▌ | 2.8MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████▋ | 2.8MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████▊ | 2.8MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████▉ | 2.8MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████████ | 2.8MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████████ | 2.8MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████████▏ | 2.8MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████████▎ | 2.8MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████████▍ | 2.8MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████████▌ | 2.9MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████████▋ | 2.9MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████████▊ | 2.9MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████████▊ | 2.9MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████████▉ | 2.9MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████████ | 2.9MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████████ | 2.9MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▏ | 2.9MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▎ | 2.9MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▍ | 2.9MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▌ | 3.0MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▋ | 3.0MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▊ | 3.0MB 10.3MB/s eta 0:00:01\r\u001b[K |█████████████████████████████▉ | 3.0MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████████ | 3.0MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████████ | 3.0MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████████ | 3.0MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▏ | 3.0MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▎ | 3.0MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▍ | 3.1MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▌ | 3.1MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▋ | 3.1MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▊ | 3.1MB 10.3MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▉ | 3.1MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████████ | 3.1MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████████ | 3.1MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▏| 3.1MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▎| 3.1MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▎| 3.1MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▍| 3.2MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▌| 3.2MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▋| 3.2MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▊| 3.2MB 10.3MB/s eta 0:00:01\r\u001b[K |███████████████████████████████▉| 3.2MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████████████| 3.2MB 10.3MB/s eta 0:00:01\r\u001b[K |████████████████████████████████| 3.2MB 10.3MB/s \n",
"\u001b[?25hCollecting service-identity>=16.0.0\n",
" Downloading https://files.pythonhosted.org/packages/e9/7c/2195b890023e098f9618d43ebc337d83c8b38d414326685339eb024db2f6/service_identity-18.1.0-py2.py3-none-any.whl\n",
"Collecting cryptography>=2.0\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/c8/52/ad7f2cbe3b6e9340526dc401b38bb67c06160449446e15b0bf5f947fa168/cryptography-2.8-cp27-cp27mu-manylinux2010_x86_64.whl (2.3MB)\n",
"\u001b[K |████████████████████████████████| 2.3MB 29.7MB/s \n",
"\u001b[?25hCollecting Twisted>=16.0.0; python_version == \"2.7\"\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/22/c2/5a30a4ad78af4d3e5df1701ec6a0dd59e1b0213dc2323dbf61b3af342ad5/Twisted-19.10.0-cp27-cp27mu-manylinux1_x86_64.whl (3.2MB)\n",
"\u001b[K |████████████████████████████████| 3.2MB 49.9MB/s \n",
"\u001b[?25hRequirement already satisfied: lxml>=3.5.0 in /usr/local/lib/python2.7/dist-packages (from scrapy) (4.2.6)\n",
"Requirement already satisfied: six>=1.10.0 in /usr/local/lib/python2.7/dist-packages (from scrapy) (1.12.0)\n",
"Collecting parsel>=1.5.0\n",
" Downloading https://files.pythonhosted.org/packages/86/c8/fc5a2f9376066905dfcca334da2a25842aedfda142c0424722e7c497798b/parsel-1.5.2-py2.py3-none-any.whl\n",
"Collecting cssselect>=0.9.1\n",
" Downloading https://files.pythonhosted.org/packages/3b/d4/3b5c17f00cce85b9a1e6f91096e1cc8e8ede2e1be8e96b87ce1ed09e92c5/cssselect-1.1.0-py2.py3-none-any.whl\n",
"Collecting w3lib>=1.17.0\n",
" Downloading https://files.pythonhosted.org/packages/6a/45/1ba17c50a0bb16bd950c9c2b92ec60d40c8ebda9f3371ae4230c437120b6/w3lib-1.21.0-py2.py3-none-any.whl\n",
"Collecting zope.interface>=4.1.3\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/d3/f0/521019b86fadc15272fd1229fbad811c4af5ad8f63a2ec604e0b50e7b473/zope.interface-4.7.1-cp27-cp27mu-manylinux2010_x86_64.whl (164kB)\n",
"\u001b[K |████████████████████████████████| 174kB 53.7MB/s \n",
"\u001b[?25hCollecting PyDispatcher>=2.0.5\n",
" Downloading https://files.pythonhosted.org/packages/cd/37/39aca520918ce1935bea9c356bcbb7ed7e52ad4e31bff9b943dfc8e7115b/PyDispatcher-2.0.5.tar.gz\n",
"Collecting queuelib>=1.4.2\n",
" Downloading https://files.pythonhosted.org/packages/4c/85/ae64e9145f39dd6d14f8af3fa809a270ef3729f3b90b3c0cf5aa242ab0d4/queuelib-1.5.0-py2.py3-none-any.whl\n",
"Requirement already satisfied: pyasn1-modules in /usr/local/lib/python2.7/dist-packages (from service-identity>=16.0.0->scrapy) (0.2.5)\n",
"Requirement already satisfied: pyasn1 in /usr/local/lib/python2.7/dist-packages (from service-identity>=16.0.0->scrapy) (0.4.5)\n",
"Requirement already satisfied: ipaddress; python_version < \"3.3\" in /usr/local/lib/python2.7/dist-packages (from service-identity>=16.0.0->scrapy) (1.0.22)\n",
"Requirement already satisfied: attrs>=16.0.0 in /usr/local/lib/python2.7/dist-packages (from service-identity>=16.0.0->scrapy) (19.1.0)\n",
"Requirement already satisfied: enum34; python_version < \"3\" in /usr/local/lib/python2.7/dist-packages (from cryptography>=2.0->scrapy) (1.1.6)\n",
"Requirement already satisfied: cffi!=1.11.3,>=1.8 in /usr/local/lib/python2.7/dist-packages (from cryptography>=2.0->scrapy) (1.12.3)\n",
"Collecting PyHamcrest>=1.9.0\n",
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/d9/6b/fb2e701f25303c620149923d98085c6d7b052d112044764cbf00cc07469e/PyHamcrest-1.10.1.tar.gz (43kB)\n",
"\u001b[K |████████████████████████████████| 51kB 8.0MB/s \n",
"\u001b[?25hCollecting hyperlink>=17.1.1\n",
" Downloading https://files.pythonhosted.org/packages/7f/91/e916ca10a2de1cb7101a9b24da546fb90ee14629e23160086cf3361c4fb8/hyperlink-19.0.0-py2.py3-none-any.whl\n",
"Collecting Automat>=0.3.0\n",
" Downloading https://files.pythonhosted.org/packages/e5/11/756922e977bb296a79ccf38e8d45cafee446733157d59bcd751d3aee57f5/Automat-0.8.0-py2.py3-none-any.whl\n",
"Collecting incremental>=16.10.1\n",
" Downloading https://files.pythonhosted.org/packages/f5/1d/c98a587dc06e107115cf4a58b49de20b19222c83d75335a192052af4c4b7/incremental-17.5.0-py2.py3-none-any.whl\n",
"Collecting constantly>=15.1\n",
" Downloading https://files.pythonhosted.org/packages/b9/65/48c1909d0c0aeae6c10213340ce682db01b48ea900a7d9fce7a7910ff318/constantly-15.1.0-py2.py3-none-any.whl\n",
"Requirement already satisfied: functools32; python_version < \"3.0\" in /usr/local/lib/python2.7/dist-packages (from parsel>=1.5.0->scrapy) (3.2.3.post2)\n",
"Requirement already satisfied: setuptools in /usr/local/lib/python2.7/dist-packages (from zope.interface>=4.1.3->scrapy) (44.0.0)\n",
"Requirement already satisfied: pycparser in /usr/local/lib/python2.7/dist-packages (from cffi!=1.11.3,>=1.8->cryptography>=2.0->scrapy) (2.19)\n",
"Requirement already satisfied: idna>=2.5 in /usr/local/lib/python2.7/dist-packages (from hyperlink>=17.1.1->Twisted>=16.0.0; python_version == \"2.7\"->scrapy) (2.8)\n",
"Building wheels for collected packages: protego, PyDispatcher, PyHamcrest\n",
" Building wheel for protego (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for protego: filename=Protego-0.1.16-cp27-none-any.whl size=7766 sha256=24400d91d4510d39cc01e5593a3f18e19f6385c106e5579f309610abd113e7ab\n",
" Stored in directory: /root/.cache/pip/wheels/51/01/d1/4a2286a976dccd025ba679acacfe37320540df0f2283ecab12\n",
" Building wheel for PyDispatcher (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for PyDispatcher: filename=PyDispatcher-2.0.5-cp27-none-any.whl size=11517 sha256=91d13022913d27810923a75bd292edc28e36db5bbbbe5ec59c953450dd0049be\n",
" Stored in directory: /root/.cache/pip/wheels/88/99/96/cfef6665f9cb1522ee6757ae5955feedf2fe25f1737f91fa7f\n",
" Building wheel for PyHamcrest (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for PyHamcrest: filename=PyHamcrest-1.10.1-cp27-none-any.whl size=48899 sha256=41a6be7cbbd43dd85cf9d12038f6c3b90d61ab6bd6ba8bbccf11182b8ba261ea\n",
" Stored in directory: /root/.cache/pip/wheels/8f/88/5d/2d12b9e226ee11ce171a603275d8dd6546d93202466b7fe173\n",
"Successfully built protego PyDispatcher PyHamcrest\n",
"Installing collected packages: cryptography, pyOpenSSL, protego, service-identity, PyHamcrest, zope.interface, hyperlink, Automat, incremental, constantly, Twisted, w3lib, cssselect, parsel, PyDispatcher, queuelib, scrapy\n",
"Successfully installed Automat-0.8.0 PyDispatcher-2.0.5 PyHamcrest-1.10.1 Twisted-19.10.0 constantly-15.1.0 cryptography-2.8 cssselect-1.1.0 hyperlink-19.0.0 incremental-17.5.0 parsel-1.5.2 protego-0.1.16 pyOpenSSL-19.1.0 queuelib-1.5.0 scrapy-1.8.0 service-identity-18.1.0 w3lib-1.21.0 zope.interface-4.7.1\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "S-qKcYCGsUNX",
"colab_type": "code",
"colab": {}
},
"source": [
"import logging\n",
"import os\n",
"import pandas as pd\n",
"import re\n",
"import scrapy\n",
"from scrapy.crawler import CrawlerProcess\n",
"from scrapy.linkextractors.lxmlhtml import LxmlLinkExtractor\n",
"from googlesearch import search\n",
"logging.getLogger('scrapy').propagate = False"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "WthIslaV9wUT",
"colab_type": "code",
"colab": {}
},
"source": [
"def get_urls(tag, n, language):\n",
" urls = [url for url in search(tag, stop=n, lang=language)][:n]\n",
" return urls"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "5oIHO6c1t-Dx",
"colab_type": "code",
"colab": {}
},
"source": [
"def returnUrls(company,ext):\n",
" query1='\\\" email *@'+company+ext+'\\\"'\n",
" query2='\\\" email **@'+company+ext+'\\\"'\n",
" query3='\\\" email ***@'+company+ext+'\\\"'\n",
" query4='\\\" email *.*@'+company+ext+'\\\"'\n",
"\n",
" l1=get_urls(query1,100,'en')\n",
" l1+=get_urls(query2,100,'en')\n",
" l1+=get_urls(query3,100,'en')\n",
" l1+=get_urls(query4,100,'en')\n",
"\n",
" return list(set(l1))\n",
"\n",
"\n"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "T286z_uhxBFI",
"colab_type": "code",
"colab": {}
},
"source": [
"ext='\\w+'"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "rT5zukATxJp0",
"colab_type": "code",
"colab": {}
},
"source": [
"class MailSpider(scrapy.Spider):\n",
" \n",
" name = 'email'\n",
" global ext\n",
"\n",
"\n",
" def parse(self, response):\n",
" \n",
" links = LxmlLinkExtractor(allow=()).extract_links(response)\n",
" links = [str(link.url) for link in links]\n",
" links.append(str(response.url))\n",
" \n",
" for link in links:\n",
" yield scrapy.Request(url=link, callback=self.parse_link) \n",
" \n",
" def parse_link(self, response):\n",
" \n",
" for word in self.reject:\n",
" if word in str(response.url):\n",
" return\n",
" \n",
" html_text = str(response.text)\n",
" mail_list = re.findall('\\w+@'+ext+'\\.{1}\\w+', html_text)\n",
"\n",
" dic = {'email': mail_list, 'link': str(response.url)}\n",
" df = pd.DataFrame(dic)\n",
" \n",
" df.to_csv(self.path, mode='a', header=False)\n",
" df.to_csv(self.path, mode='a', header=False)"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "yzWbLMxs01zd",
"colab_type": "code",
"colab": {}
},
"source": [
"def ask_user(question):\n",
" response = input(question + ' y/n' + '\\n')\n",
" if response == 'y':\n",
" return True\n",
" else:\n",
" return False\n",
"def create_file(path):\n",
" response = False\n",
" if os.path.exists(path):\n",
" response = ask_user('File already exists, replace?')\n",
" if response == False: return \n",
" \n",
" with open(path, 'wb') as file: \n",
" file.close()"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "uEiorM-01XOX",
"colab_type": "code",
"colab": {}
},
"source": [
"def get_info(tag,ext, n, language, path, reject=[]):\n",
" \n",
" create_file(path)\n",
" df = pd.DataFrame(columns=['email', 'link'], index=[0])\n",
" df.to_csv(path, mode='w', header=True)\n",
" \n",
" print('Collecting Google urls...')\n",
" google_urls = get_urls(tag,n,language)\n",
" #returnUrls(tag,ext)\n",
" \n",
" print('Searching for emails...')\n",
" process = CrawlerProcess({'USER_AGENT': 'Mozilla/5.0'})\n",
" process.crawl(MailSpider, start_urls=google_urls, path=path, reject=reject)\n",
" process.start()\n",
" \n",
" print('Cleaning emails...')\n",
" df = pd.read_csv(path, index_col=0)\n",
" df.columns = ['email', 'link']\n",
" df = df.drop_duplicates(subset='email')\n",
" df = df.reset_index(drop=True)\n",
" df.to_csv(path, mode='w', header=True)\n",
" \n",
" return df"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "vSrkIEfj1ci_",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 68
},
"outputId": "c3329d53-d8db-418b-a649-54ec6ecb5e16"
},
"source": [
"bad_words = ['facebook', 'instagram', 'youtube', 'twitter', 'wiki']\n",
"df = get_info('Real Estate Companies in New York City','.com', 300, 'en', 'studios.csv', reject=bad_words)"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"Collecting Google urls...\n",
"Searching for emails...\n"
],
"name": "stdout"
},
{
"output_type": "stream",
"text": [
"No handlers could be found for logger \"scrapy.utils.log\"\n"
],
"name": "stderr"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment