email2face 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -1
- data/Gemfile.lock +0 -1
- data/README.md +19 -9
- data/VERSION +1 -1
- data/email2face.gemspec +1 -4
- data/lib/email2face.rb +29 -58
- metadata +2 -18
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@ You give it an email. It gives you their face.
|
|
4
4
|
|
5
5
|
## Dependencies & Warnings
|
6
6
|
|
7
|
-
It needs a Facebook account to work. I *do not* recommend using your own Facebook
|
7
|
+
It needs a Facebook account to work. I *do not* recommend using your own Facebook because it stores the Facebook account in plaintext. So, make a fake Facebook for it. I've included a default one, but it'll probably be banned by the time you get to it.
|
8
8
|
|
9
9
|
### Before jumping in
|
10
10
|
|
@@ -29,8 +29,6 @@ $ sudo pacman -S xorg-server-xvfb qtwebkit
|
|
29
29
|
$ sudo apt-get install xvfb libqtwebkit4 libqtwebkit4-dev
|
30
30
|
```
|
31
31
|
|
32
|
-
**You need to make a fake Facebook account to use this!**
|
33
|
-
|
34
32
|
## Using it
|
35
33
|
|
36
34
|
Start off by installing the gem:
|
@@ -39,17 +37,29 @@ Start off by installing the gem:
|
|
39
37
|
gem install 'email2face'
|
40
38
|
```
|
41
39
|
|
42
|
-
Then, we
|
40
|
+
Then, we just give Email2Face the email we want a face for:
|
43
41
|
|
44
42
|
```ruby
|
45
43
|
require 'email2face'
|
46
44
|
Email2Face.face("my.email@facebook.com")
|
47
45
|
```
|
48
|
-
I've included a fake Facebook by default. However, it could be disabled at any time.
|
49
46
|
|
50
|
-
|
47
|
+
### Changing the Facebook Account
|
48
|
+
It's unlikely the included Facebook account will work for long. So, you may need to make a fake Facebook for it. Do not use your own because it's possible that Facebook may ban it.
|
49
|
+
|
50
|
+
#### With Ruby on Rails:
|
51
|
+
|
52
|
+
* Create a new file in `config/initializers` called `facebook.rb`
|
53
|
+
|
54
|
+
* Open that file in a text editor, and drop in the following:
|
51
55
|
|
52
56
|
```ruby
|
53
|
-
|
54
|
-
Email2Face.
|
55
|
-
```
|
57
|
+
Email2Face.username = "FAKE_FACEBOOK_USERNAME"
|
58
|
+
Email2Face.password = "FAKE_FACEBOOK_PASSWORD"
|
59
|
+
```
|
60
|
+
|
61
|
+
You'll need to restart your application server for it to have any affect.
|
62
|
+
|
63
|
+
#### Without Ruby on Rails:
|
64
|
+
|
65
|
+
The code above wasn't specific to Ruby on Rails. Just set ```Email2Face.username``` and ```Email2Face.password``` to what you want.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/email2face.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "email2face"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jarred Sumner"]
|
@@ -39,7 +39,6 @@ Gem::Specification.new do |s|
|
|
39
39
|
s.specification_version = 3
|
40
40
|
|
41
41
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
42
|
-
s.add_runtime_dependency(%q<json>, [">= 0"])
|
43
42
|
s.add_runtime_dependency(%q<capybara>, [">= 0"])
|
44
43
|
s.add_runtime_dependency(%q<capybara-webkit>, [">= 0"])
|
45
44
|
s.add_runtime_dependency(%q<headless>, [">= 0"])
|
@@ -49,7 +48,6 @@ Gem::Specification.new do |s|
|
|
49
48
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
50
49
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
51
50
|
else
|
52
|
-
s.add_dependency(%q<json>, [">= 0"])
|
53
51
|
s.add_dependency(%q<capybara>, [">= 0"])
|
54
52
|
s.add_dependency(%q<capybara-webkit>, [">= 0"])
|
55
53
|
s.add_dependency(%q<headless>, [">= 0"])
|
@@ -60,7 +58,6 @@ Gem::Specification.new do |s|
|
|
60
58
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
61
59
|
end
|
62
60
|
else
|
63
|
-
s.add_dependency(%q<json>, [">= 0"])
|
64
61
|
s.add_dependency(%q<capybara>, [">= 0"])
|
65
62
|
s.add_dependency(%q<capybara-webkit>, [">= 0"])
|
66
63
|
s.add_dependency(%q<headless>, [">= 0"])
|
data/lib/email2face.rb
CHANGED
@@ -1,54 +1,45 @@
|
|
1
1
|
require 'capybara/dsl'
|
2
2
|
require 'capybara-webkit'
|
3
3
|
require 'headless'
|
4
|
-
|
4
|
+
|
5
|
+
FAKE_FACEBOOK_USERNAME = "anmail@email2face.net"
|
6
|
+
FAKE_FACEBOOK_PASSWORD = "thisisapassword"
|
5
7
|
|
6
8
|
class Email2Face
|
7
|
-
|
9
|
+
# This is why you should make a fake Facebook account.
|
10
|
+
@@username = FAKE_FACEBOOK_USERNAME
|
11
|
+
@@password = FAKE_FACEBOOK_PASSWORD
|
8
12
|
|
9
|
-
def self.
|
10
|
-
|
13
|
+
def self.username
|
14
|
+
@@username
|
11
15
|
end
|
12
16
|
|
13
|
-
|
14
|
-
|
17
|
+
def self.username=(username)
|
18
|
+
@@username = username
|
19
|
+
end
|
15
20
|
|
16
|
-
def self.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
user.password = options[:password]
|
23
|
-
user.verbose = options[:verbose]
|
24
|
-
end
|
25
|
-
if user.username.nil? || user.username == "" || user.password.nil? || user.password == ""
|
26
|
-
user.no_login_details(email)
|
27
|
-
end
|
28
|
-
html = user.face_html(email)
|
29
|
-
return user.face(html)
|
21
|
+
def self.password
|
22
|
+
@@password
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.password=(password)
|
26
|
+
@@password = password
|
30
27
|
end
|
31
28
|
|
32
|
-
def
|
33
|
-
if
|
34
|
-
|
35
|
-
self.username = json["username"]
|
36
|
-
self.password = json["password"]
|
37
|
-
self.verbose = options["verbose"]
|
29
|
+
def self.face(email)
|
30
|
+
if @@username == FAKE_FACEBOOK_USERNAME
|
31
|
+
no_login_details(email)
|
38
32
|
end
|
33
|
+
html = face_html(email)
|
34
|
+
return get_face(html)
|
39
35
|
end
|
40
36
|
|
41
|
-
def no_login_details(email)
|
42
|
-
|
43
|
-
options[:username] = 'anmail@email2face.net'
|
44
|
-
options[:password] = 'thisisapassword'
|
45
|
-
puts "You didn't specify a Facebook account, so I set you up with a fake Facebook account that might not work. When it stops working, just open up \"#{Email2Face.filepath}\" and change it there"
|
46
|
-
Email2Face.face(email, options)
|
37
|
+
def self.no_login_details(email)
|
38
|
+
puts "You didn't specify a Facebook account, so I set you up with a fake Facebook account that might not work."
|
47
39
|
end
|
48
40
|
|
49
|
-
def face_html(email)
|
41
|
+
def self.face_html(email)
|
50
42
|
configure_capybara
|
51
|
-
puts "Logging in..." if self.verbose
|
52
43
|
Headless.ly do
|
53
44
|
browser = Capybara::Session.new(:webkit, browser)
|
54
45
|
#self.driver.header("User-Agent", CHROME_USER_AGENT)
|
@@ -59,8 +50,6 @@ class Email2Face
|
|
59
50
|
browser.click_button "Log In"
|
60
51
|
end
|
61
52
|
if browser.driver.cookies["c_user", ".facebook.com"]
|
62
|
-
login_success!
|
63
|
-
puts "Login Successful! Getting Face URL" if self.verbose
|
64
53
|
url = "https://www.facebook.com/search/results.php?o=2048&init=s%3Aemail&q=#{ email.sub("@", "%40") }"
|
65
54
|
browser.visit url
|
66
55
|
return browser.html
|
@@ -70,30 +59,12 @@ class Email2Face
|
|
70
59
|
end
|
71
60
|
end
|
72
61
|
|
73
|
-
def
|
74
|
-
if File.exists?(Email2Face.filepath)
|
75
|
-
File.delete(Email2Face.filepath)
|
76
|
-
else
|
77
|
-
File.new(Email2Face.filepath, "w")
|
78
|
-
end
|
79
|
-
File.open(Email2Face.filepath, "w") do |f|
|
80
|
-
f.write(self.to_json)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def to_json
|
85
|
-
hash = Hash.new
|
86
|
-
hash[:username] = self.username
|
87
|
-
hash[:password] = self.password
|
88
|
-
hash.to_json
|
89
|
-
end
|
90
|
-
|
91
|
-
def login_failed!
|
62
|
+
def self.login_failed!
|
92
63
|
puts "Couldn't login to Facebook. Maybe you misspelled your username or password?"
|
93
64
|
exit(0)
|
94
65
|
end
|
95
66
|
|
96
|
-
def
|
67
|
+
def self.get_face(html)
|
97
68
|
parser = Nokogiri::HTML(html)
|
98
69
|
element = parser.xpath("//*[@id='pagelet_search_results_objects']/div/div/div/div/div[2]/div[1]/a") || parser.xpath('//*[@id="js_0"]')
|
99
70
|
href = element.attribute("href")
|
@@ -101,11 +72,11 @@ class Email2Face
|
|
101
72
|
uri.host = "graph.facebook.com"
|
102
73
|
uri.path = uri.path + "/picture"
|
103
74
|
uri.to_s
|
104
|
-
rescue
|
75
|
+
rescue
|
105
76
|
"I couldn't find a face for that email :("
|
106
77
|
end
|
107
78
|
|
108
|
-
def configure_capybara
|
79
|
+
def self.configure_capybara
|
109
80
|
Capybara.app = self
|
110
81
|
Capybara.javascript_driver = :webkit
|
111
82
|
Capybara.current_driver = :webkit
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email2face
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,22 +11,6 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-05-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: json
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
14
|
- !ruby/object:Gem::Dependency
|
31
15
|
name: capybara
|
32
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,7 +176,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
176
|
version: '0'
|
193
177
|
segments:
|
194
178
|
- 0
|
195
|
-
hash: -
|
179
|
+
hash: -83936141
|
196
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
197
181
|
none: false
|
198
182
|
requirements:
|