mirror of
https://github.com/metafy-social/python-scripts.git
synced 2025-03-10 23:59:49 +00:00
commit
3b7fd18cee
16
scripts/Email Extractor/README.md
Normal file
16
scripts/Email Extractor/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Email Extractor with Python
|
||||
|
||||
This is a script that takes input as a website and collect all the email address into a csv file.
|
||||
|
||||
|
||||
### Setup
|
||||
- Install the requirements (refer below)
|
||||
- Run the script by 'python email_extractor.py'
|
||||
- Input the website to collect emails
|
||||
|
||||
|
||||
### Requirements
|
||||
```pip install -r requirements.txt```
|
||||
|
||||
### usage
|
||||
```python email_extractor.py```
|
45
scripts/Email Extractor/email_extractor.py
Normal file
45
scripts/Email Extractor/email_extractor.py
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import urllib.request
|
||||
from email_scraper import scrape_emails
|
||||
import pandas as pd
|
||||
from google.colab import files
|
||||
|
||||
|
||||
urlid = input("Enter Website url (i.e.: example.com): ")
|
||||
url = "https://"+urlid+"/"
|
||||
reqs = requests.get(url)
|
||||
soup = BeautifulSoup(reqs.text, 'html.parser')
|
||||
|
||||
urls = []
|
||||
response = []
|
||||
email = []
|
||||
for link in soup.find_all('a'):
|
||||
urls.append(link.get('href'))
|
||||
for i in range(len(urls)):
|
||||
if(urls[i].startswith("https://")):
|
||||
fp = urllib.request.urlopen(url+urls[i])
|
||||
mybytes = fp.read()
|
||||
mystr = mybytes.decode("utf8")
|
||||
fp.close()
|
||||
response.append(scrape_emails(mystr))
|
||||
else:
|
||||
fp = urllib.request.urlopen(url+urls[i])
|
||||
mybytes = fp.read()
|
||||
mystr = mybytes.decode("utf8")
|
||||
fp.close()
|
||||
response.append(scrape_emails(mystr))
|
||||
|
||||
for r in range(len(response)):
|
||||
if not response[r]:
|
||||
continue
|
||||
else:
|
||||
email.append(response[r])
|
||||
|
||||
df = pd.DataFrame(email, columns=["Email"])
|
||||
df.to_csv('email.csv', index=False)
|
||||
|
||||
files.download("email.csv")
|
||||
|
6
scripts/Email Extractor/requirements.txt
Normal file
6
scripts/Email Extractor/requirements.txt
Normal file
@ -0,0 +1,6 @@
|
||||
pip install requests
|
||||
pip install bs4
|
||||
pip install urllib
|
||||
pip install email_scraper
|
||||
pip install pandas
|
||||
pip install google
|
Loading…
x
Reference in New Issue
Block a user