Skip to content

Commit

Permalink
added json
Browse files Browse the repository at this point in the history
  • Loading branch information
Arshdeep Singh committed Jan 27, 2018
1 parent 8a4811e commit 9f9d91a
Show file tree
Hide file tree
Showing 10 changed files with 4,286 additions and 11 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
test.py
*.json
environment.sh
logfile.txt
__pycache__
17 changes: 13 additions & 4 deletions facebookbot/bot.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
import facebook
import os
import requests

app_id = "340963926402035"
app_secret = "b9c46f67e14f5d69c343e0df06bea0bd"

graph = facebook.GraphAPI(access_token='EAACEdEose0cBADJY4EEZCKw86CA5LFt5NXelh7weB0F6EHKVodV6Jb2Vt6nmtuqZB2ZCwCuf486Gsfw0rcJruSLZARlaJlH7I52mIYanPJPgyiFZBt9acFr9AQCdktKt99R52inH9cG1sMyZA5MvuOZAcxwfUF1P3Q0VUiBvmhzeJlIrFNsEV9BuMsGfHE1wBvUy2SkYZBiBOgZDZD', version="2.10")
def get_fb_token(app_id, app_secret):
payload = {'grant_type': 'client_credentials', 'client_id': app_id, 'client_secret': app_secret}
file = requests.post('https://graph.facebook.com/oauth/access_token?', params = payload)
#print file.text #to test what the FB api responded with
result = file.json()['access_token']
#print file.text #to test the TOKEN
return result

graph = facebook.GraphAPI(access_token='EAACEdEose0cBAAUoPkaEZBZADr1W5xpcHoMioICVaVbkWZBYB9ciclWZAZBsyF0KEZBZAslc8EICxChAsUdoSBytirO3gTYfACEEI5qQCVx88QsT1fuHZBl9ZBkTZB3pxvZBCP0A88TWpz0NlDeS0zQ1oOs8Pw36LJcvB3kINwO90fdq8dETIPoE5cQZCOeg15Kgqzo0CvngqJXlLAZDZD', version="2.10")
# get_app_access_token(app_id, app_secret)

users = graph.search(type='user', q='4rshdeep')
# users = graph.search(type='user', q='4rshdeep')

for user in users['data']:
print('%s %s' % (user['id'],user['name'].encode()))
# for user in users['data']:
# print('%s %s' % (user['id'],user['name'].encode()))



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
3,751 changes: 3,751 additions & 0 deletions facebookbot/facebook-page-post-scraper/531752773523381_facebook_statuses.csv

Large diffs are not rendered by default.

273 changes: 273 additions & 0 deletions facebookbot/facebook-page-post-scraper/Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>status_id</th>\n",
" <th>status_message</th>\n",
" <th>status_author</th>\n",
" <th>link_name</th>\n",
" <th>status_type</th>\n",
" <th>status_link</th>\n",
" <th>status_published</th>\n",
" <th>num_reactions</th>\n",
" <th>num_comments</th>\n",
" <th>num_shares</th>\n",
" <th>num_likes</th>\n",
" <th>num_loves</th>\n",
" <th>num_wows</th>\n",
" <th>num_hahas</th>\n",
" <th>num_sads</th>\n",
" <th>num_angrys</th>\n",
" <th>num_special</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>531752773523381_1767214209977225</td>\n",
" <td>🇨🇦🇧🇷🇪🇺🇯🇵🇰🇷🇮🇳🇿🇦🇪🇸🇻🇪🇹🇴🇬🇧🇺🇸🇿🇼🇨🇴🇨🇿🇩🇴🇫🇮🇫🇷🇩🇪🇮🇩🇮🇪🇲🇳🇳🇿...</td>\n",
" <td>Svetlana Vorontsova</td>\n",
" <td>Partnership Fundraising: The Business of the 2...</td>\n",
" <td>link</td>\n",
" <td>http://www.passive-income-learn-why-here-link.ru/</td>\n",
" <td>2018-01-26 18:46:33</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>531752773523381_1767176869980959</td>\n",
" <td>NaN</td>\n",
" <td>Hon Adedeji Sikiru</td>\n",
" <td>Natural Freshwater Pearl Jewelry Set w/Sterlin...</td>\n",
" <td>link</td>\n",
" <td>http://www.gotclicks1.com/xHw7Vvc5mbsZ</td>\n",
" <td>2018-01-26 17:49:24</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>531752773523381_1767169219981724</td>\n",
" <td>NaN</td>\n",
" <td>Jonar Fabula</td>\n",
" <td>NaN</td>\n",
" <td>status</td>\n",
" <td>NaN</td>\n",
" <td>2018-01-26 17:35:54</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>531752773523381_1767148543317125</td>\n",
" <td>NaN</td>\n",
" <td>David Smith</td>\n",
" <td>Let's Vagabond</td>\n",
" <td>photo</td>\n",
" <td>https://www.facebook.com/letsvagabond/photos/a...</td>\n",
" <td>2018-01-26 17:05:07</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>531752773523381_1767139313318048</td>\n",
" <td>Per Week Earn Over $700 . ANYONE who knows how...</td>\n",
" <td>Lopa Lota</td>\n",
" <td>NaN</td>\n",
" <td>status</td>\n",
" <td>NaN</td>\n",
" <td>2018-01-26 16:49:55</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" status_id \\\n",
"0 531752773523381_1767214209977225 \n",
"1 531752773523381_1767176869980959 \n",
"2 531752773523381_1767169219981724 \n",
"3 531752773523381_1767148543317125 \n",
"4 531752773523381_1767139313318048 \n",
"\n",
" status_message status_author \\\n",
"0 🇨🇦🇧🇷🇪🇺🇯🇵🇰🇷🇮🇳🇿🇦🇪🇸🇻🇪🇹🇴🇬🇧🇺🇸🇿🇼🇨🇴🇨🇿🇩🇴🇫🇮🇫🇷🇩🇪🇮🇩🇮🇪🇲🇳🇳🇿... Svetlana Vorontsova \n",
"1 NaN Hon Adedeji Sikiru \n",
"2 NaN Jonar Fabula \n",
"3 NaN David Smith \n",
"4 Per Week Earn Over $700 . ANYONE who knows how... Lopa Lota \n",
"\n",
" link_name status_type \\\n",
"0 Partnership Fundraising: The Business of the 2... link \n",
"1 Natural Freshwater Pearl Jewelry Set w/Sterlin... link \n",
"2 NaN status \n",
"3 Let's Vagabond photo \n",
"4 NaN status \n",
"\n",
" status_link status_published \\\n",
"0 http://www.passive-income-learn-why-here-link.ru/ 2018-01-26 18:46:33 \n",
"1 http://www.gotclicks1.com/xHw7Vvc5mbsZ 2018-01-26 17:49:24 \n",
"2 NaN 2018-01-26 17:35:54 \n",
"3 https://www.facebook.com/letsvagabond/photos/a... 2018-01-26 17:05:07 \n",
"4 NaN 2018-01-26 16:49:55 \n",
"\n",
" num_reactions num_comments num_shares num_likes num_loves num_wows \\\n",
"0 0 0 0 0 0 0 \n",
"1 0 0 0 0 0 0 \n",
"2 0 0 0 0 0 0 \n",
"3 0 0 0 0 0 0 \n",
"4 0 0 0 0 0 0 \n",
"\n",
" num_hahas num_sads num_angrys num_special \n",
"0 0 0 0 0 \n",
"1 0 0 0 0 \n",
"2 0 0 0 0 \n",
"3 0 0 0 0 \n",
"4 0 0 0 0 "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.read_csv('531752773523381_facebook_statuses.csv')\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Index(['status_id', 'status_message', 'status_author', 'link_name',\n",
" 'status_type', 'status_link', 'status_published', 'num_reactions',\n",
" 'num_comments', 'num_shares', 'num_likes', 'num_loves', 'num_wows',\n",
" 'num_hahas', 'num_sads', 'num_angrys', 'num_special'],\n",
" dtype='object')"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.columns"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,9 @@ def request_until_succeed(url):
success = False
while success is False:
try:
<<<<<<< HEAD
response = requests.get(url, proxies = proxyDict)
if response.status_code == 200:
success = True
=======
response = requests.get(url)
# if response.getcode() == 200:
# success = True
>>>>>>> 3e349e852b543ba36a4bbda9736e957393e6734f
except Exception as e:
print(e)
time.sleep(5)
Expand Down
1 change: 1 addition & 0 deletions instabot/examples/model.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions instabot/instabot/bot/model.json

Large diffs are not rendered by default.

Loading

0 comments on commit 9f9d91a

Please sign in to comment.