How To Create Facebook Login Form Scrapper Using Python Mechanize Module - | python web scraping | python example - part 14

Hello Friends,


                           This is our 14th part of web scraping tutorials. and In this Tutorials, I am Going To Show You How To Use Python Mechanize Module Against Facebook Website. or You Can Say Today's Tutorials Is About How To Deal With Facebook Login Forms using python.


so, let's talk about today's topic.


Today's Tutorials really gonna very juice and very interesting because here, you will see how we can easily use mechanize module against login form with the Facebook example.


so, don't skip any line or any content.

read carefully and try to understand these examples because i tried my best for creating these examples 
easy to understand and easy to remember with lots of comments.
and for future update follow us.

But, if you are a new visitor, then first check our index or
if You Wants More Information About Python Mechanize Module Then Check This Complete Tutorial. (12th Part) Click Here

and for mechanize complete tutorial click here.



 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/python
# -*- coding: utf-8 -*-

__author__='''

######################################################
                By S.S.B Group                          
######################################################

    Suraj Singh
    Admin
    S.S.B Group
    surajsinghbisht054@gmail.com
    http://bitforestinfo.blogspot.in/

    Note: We Feel Proud To Be Indian
######################################################
#
# ---------------- READ ME ---------------------------------------------
# This Script is Created For Practise And Educational Purpose Only
# I will Not Take Any Type Of Responsibility.
# Use This Script On Your Own Responsibility.
# No Warranty, No Responsibility
# This Script Is Only A Example. Created For http://bitforestinfo.blogspot.com

'''
print __author__
# Import Modules
import mechanize
import cookielib
import cookielib
import sys

# Take User Inputs
user=raw_input('[+] Facebook A/c Username : ')  # UserName
password=raw_input('[+] Facebook A/c Password : ') # Password

# Facebook Login Page Url
login='https://m.facebook.com/login.php?login_attempt=1'

# Creating Browser
br = mechanize.Browser()

# Browser Configurations
cj=cookielib.LWPCookieJar()
br.set_handle_robots(False)
br.set_handle_equiv(True)
br.set_handle_referer(True)
br.set_handle_redirect(True)
br.set_cookiejar(cj)
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) 

# User Agent
k=('Mozilla/5.0 (BeOS; U; BeOS BeBox; fr; rv:1.9) Gecko/2008052906 BonEcho/2.0')

print " [+] User Agent : ", k

# Add User Agent In Header
br.addheaders = [('User-agent', k)]

print " [+]   Please Wait Loading Page .... [+]"

# Try To Get Login Page
try:
 # Open Login Page
    site = br.open(login)

except Exception as e:
 # Print Error
 print e
 print " [+] Please Check Internet Connections " 
 sys.exit(0) 

# Now Login Page Is Ready 
try:
 br._factory.is_html = True
except Exception as e:
 print e

# Select Form By Index
br.select_form(nr=0)

# Enter Username
br.form['email']=user

# Enter Password
br.form['pass']=password

# Now Submit
br.submit()

# Get Url
log=br.geturl()

# Check Login Page Url
if ".facebook.com/home.php" in log:
 print " [+] [=]   Login Sucessful   [=] [+] "    
else:
 print "[*] Enable To Login"



For More Update, Visit Our Blog Regularly. 
, Subscribe Our Blog, 
Follow Us and share it
.
For Any Type of Suggestion, Help Or Question
Contact me:
S.S.B
surajsinghbisht054@gmail.com

or Comment Below

Share this

Related Posts

Previous
Next Post »