fb_scrape 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/fb_scrape +24 -0
- data/lib/fb_scrape/client.rb +4 -1
- data/lib/fb_scrape/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29b58f6847d52acf4ddb42d640ec83381bfd98e2
|
4
|
+
data.tar.gz: 3515cb9e1354420f8ffd7e87ae4c175ff17ee137
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61813248a7541451c4094330fea755093473df2afc2ccf636f75348a3a5c1d32bbbdcd5f86d8669f21fe55a26b34e50b43b9fb9d0a5c73dcbe5b402f8224d7e0
|
7
|
+
data.tar.gz: 3ca16bfe693e365e770664424b2f50aa2d3faab081fa595460627e99f44d2038269dd4c50553677a0941ec9005d9334692548df744b24b0f87389d165b5ec35e
|
data/bin/fb_scrape
CHANGED
@@ -60,6 +60,30 @@ class FBScrape::CLI < Thor
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
desc "export_messages", "Get all the comments for a post's shortcode"
|
64
|
+
option :limit, :required => true
|
65
|
+
option :token, :required => true
|
66
|
+
option :page_id, :required => true
|
67
|
+
option :out_file, :required => true
|
68
|
+
def export_messages
|
69
|
+
begin
|
70
|
+
# exports all a pages conversation threads to a csv file$T
|
71
|
+
client = FBScrape::Client.new(nil, options[:token], options[:page_id])
|
72
|
+
client.load_conversations(options[:limit])
|
73
|
+
|
74
|
+
client.conversations.each do |c|
|
75
|
+
c.load_messages
|
76
|
+
puts "Loading #{c.id} messages: #{c.messages.count}"
|
77
|
+
end
|
78
|
+
|
79
|
+
messages = client.conversations.collect{ |c| c.messages }.flatten
|
80
|
+
puts "Total messages #{messages.count}"
|
81
|
+
|
82
|
+
rescue ArgumentError => e
|
83
|
+
puts e.message
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
63
87
|
end
|
64
88
|
|
65
89
|
FBScrape::CLI.start(ARGV)
|
data/lib/fb_scrape/client.rb
CHANGED
@@ -52,8 +52,8 @@ class FBScrape::Client
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def load_conversations(limit=nil)
|
55
|
-
load_initial_conversations
|
56
55
|
@limit = limit if limit != @limit
|
56
|
+
load_initial_conversations
|
57
57
|
|
58
58
|
while has_more_conversations? && can_load_more_conversations? do
|
59
59
|
load_more_conversations
|
@@ -65,6 +65,9 @@ class FBScrape::Client
|
|
65
65
|
def load_initial_conversations
|
66
66
|
if !@loaded_initial_conversations
|
67
67
|
url = "https://graph.facebook.com/v#{FBScrape::GRAPH_VERSION}/#{@id}/conversations?access_token=#{@token_secret}"
|
68
|
+
if is_limited?
|
69
|
+
url += "&limit=#{@limit}"
|
70
|
+
end
|
68
71
|
load_conversations_from_url url
|
69
72
|
@loaded_initial_conversations = true
|
70
73
|
end
|
data/lib/fb_scrape/version.rb
CHANGED