Welcome, guest | Sign In | My Account | Store | Cart

This script will allow you to send Messages to people who have a username on facebook from an email id you specify in the script.Although message will not be sent to their inbox,if you're not a friend but it will be sent to other category.

Python, 75 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#usr/bin/env/python
"""
This script can get the user data from facebook.com.
This is written for better understanding of python 
Modules required:BeautifulSoup
Author:Ajay Kumar Medepalli aka Cybercam
Blog:http://pythonnotesbyajay.blogspot.in/

"""
import smtplib
import email
from email.MIMEMultipart import MIMEMultipart
from email.parser import Parser
from email.MIMEText import MIMEText
import urllib2
from BeautifulSoup import BeautifulSoup
import random

user_name_array=[]
def get_fb_username(id):
    try:
        url=urllib2.urlopen('https://graph.facebook.com/'+str(id)).read()
        soup = BeautifulSoup(url)
        all_attr=soup.prettify()
        print all_attr
        gend=all_attr.find("gender")
        if(all_attr[gend+9] == 'm'):
            gender='male'
        elif (all_attr[gend+9] == 'f'):
            gender = 'female'
        else:
            gender="The user didn't specify any gender"
        if all_attr.find('username') != -1:
            start_quote=all_attr.find('username')+10
            end_quote=all_attr.find('"',start_quote+1)
            user_name=all_attr[start_quote:end_quote+1].strip('"')+'@facebook.com'

            user_name_array.append(user_name)
            print "username ==>"+'\t'+user_name +'\t'+ "gender ==>"+"\t"+gender
            print "\n"
        
    except urllib2.HTTPError:
        pass


    

for i in range(4,10,1):
#for i in range(startvalue,stopvalue,stepvalue):
    get_fb_username(i+1)
print user_name_array

def send_mail():
    random_text=["hi","hello","Nice to meet you","How are you","wassup","hi!!!",'just wanted to say hi']
    server = smtplib.SMTP()
    server.connect('smtp.gmail.com', 587) # for eg. host = 'smtp.gmail.com', port = 587
    server.ehlo()
    server.starttls()
    server.login('username@gmail.com', 'password')
    #replace this with u r gmail id
    #password ==> ur gmail password
    fromaddr ='username@gmail.com'

    for i in range(len(user_name_array)-1):

        msg = email.MIMEMultipart.MIMEMultipart()
        msg['From'] = fromaddr
        msg['To'] = user_name_array[i]
        msg['Subject'] = 'hi'
        
        msg.attach(MIMEText(random_text[random.randint(0,len(random_text)-1)]))
        #msg.attach(MIMEText('put some custom message.', 'plain')) 
        server.sendmail(fromaddr,user_name_array[i],msg.as_string())
    server.quit()  
send_mail()

3 comments

AJay Kumar (author) 8 years, 4 months ago  # | flag

This is the dumbest script written ever

SirVon A Thomas 8 years, 1 month ago  # | flag

I just made an account on this site to say.... NO, this is one of the smartest uses to market widely and for free on facebook!

Nice Work!

Eiver 6 years, 2 months ago  # | flag

Awesome Script. I guess fb has altogether banned the idea of fb email becasuse of this script.