Skip to content

Commit 69b2c39

Browse files
first commit
0 parents commit 69b2c39

File tree

7 files changed

+299
-0
lines changed

7 files changed

+299
-0
lines changed

rapagemFacebook/Consult.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import facebook
2+
import requests
3+
import json
4+
from collections import namedtuple
5+
6+
# connect banco
7+
from firebase import firebase
8+
firebase = firebase.FirebaseApplication('https://you_domin.firebaseio.com/')
9+
10+
# config facebookAPI
11+
access_token ="you_token"
12+
graph = facebook.GraphAPI(access_token)
13+
14+
15+
pergunta = 'Hospital' # pesquisa por paginas com esse nome
16+
directFile = 'pesquisas/'+pergunta+'.json'
17+
18+
19+
arquivo = open(directFile, 'r')
20+
unica_string = arquivo.read()
21+
arquivo.close()
22+
23+
# transformando em OBJETO
24+
x = json.loads(unica_string, object_hook=lambda d: namedtuple('X', d.keys())(*d.values()))
25+
26+
id_consult = []
27+
# atribuindo valres
28+
for place in x.Hospital.data:
29+
id_consult.append( str(place.id) )
30+
31+
result_all_feeds = []
32+
33+
for event in id_consult:
34+
feeds = graph.get_connections(event,
35+
connection_name="feed",
36+
fields="message,name,comments,created_time")
37+
result_all_feeds.append( feeds['data'] )
38+
39+
40+
directFile_result = 'pesquisas/result_all_feeds'+pergunta+'.json'
41+
directDB = pergunta+'result_all'
42+
43+
44+
with open( directFile_result, 'w') as fp:
45+
json.dump(result_all_feeds, fp)
46+
47+
# Firebase
48+
firebase.post(directDB, result_all_feeds)
49+
50+
print ( 'ok...')
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
{
2+
"Hospital" : {
3+
"data" : [ {
4+
"id" : "113001758777735",
5+
"location" : {
6+
"city" : "Fortaleza",
7+
"country" : "Brazil",
8+
"latitude" : -3.7794174813012,
9+
"longitude" : -38.571845659805,
10+
"state" : "CE",
11+
"zip" : "60720000"
12+
},
13+
"name" : "Hospital Frotinha Parangaba Maria José Barroso"
14+
}, {
15+
"id" : "762048590486273",
16+
"location" : {
17+
"city" : "Fortaleza",
18+
"country" : "Brazil",
19+
"latitude" : -3.7320677364768,
20+
"longitude" : -38.493488929223,
21+
"state" : "CE",
22+
"street" : "Rua República do Líbano, 747 - Meireles"
23+
},
24+
"name" : "Hospital Monte Klinikum"
25+
}, {
26+
"id" : "834455253336683",
27+
"location" : {
28+
"city" : "Fortaleza",
29+
"country" : "Brazil",
30+
"latitude" : -3.7304401,
31+
"longitude" : -38.5286331,
32+
"state" : "CE",
33+
"street" : "Rua Major Facundo, 847",
34+
"zip" : "60025-100"
35+
},
36+
"name" : "Odonto Center"
37+
}, {
38+
"id" : "305060489630458",
39+
"location" : {
40+
"city" : "Fortaleza",
41+
"country" : "Brazil",
42+
"latitude" : -3.73433,
43+
"longitude" : -38.53072,
44+
"state" : "CE",
45+
"street" : "Av. Barão do Rio Branco 1835",
46+
"zip" : "60025-061"
47+
},
48+
"name" : "Império Hospitalar"
49+
}, {
50+
"id" : "362112277493946",
51+
"location" : {
52+
"city" : "Icó",
53+
"country" : "Brazil",
54+
"latitude" : -6.40352,
55+
"longitude" : -38.8599699,
56+
"state" : "CE",
57+
"street" : "Av. Josefa Nogueira Monteiro S/N",
58+
"zip" : "63.430 - 000"
59+
},
60+
"name" : "Hospital Regional de Icó."
61+
}, {
62+
"id" : "225541254132055",
63+
"location" : {
64+
"city" : "Teresina",
65+
"country" : "Brazil",
66+
"latitude" : -5.0964995165101,
67+
"longitude" : -42.810755613435,
68+
"state" : "PI",
69+
"street" : "Rua São João, 1262",
70+
"zip" : "64001-360"
71+
},
72+
"name" : "Unimed Teresina"
73+
}, {
74+
"id" : "6435441794",
75+
"location" : {
76+
"city" : "Memphis",
77+
"country" : "United States",
78+
"latitude" : 35.153243172262,
79+
"longitude" : -90.043481558707,
80+
"state" : "TN",
81+
"street" : "501 Saint Jude Pl",
82+
"zip" : "38105"
83+
},
84+
"name" : "St. Jude Children's Research Hospital"
85+
}, {
86+
"id" : "871305996291012",
87+
"location" : {
88+
"city" : "Ceará",
89+
"country" : "Brazil",
90+
"latitude" : -3.7359454333333,
91+
"longitude" : -38.656924133333,
92+
"state" : "CE",
93+
"zip" : "60015-000"
94+
},
95+
"name" : "HGCC Hospital Geral César Cals - Fortaleza, Ce"
96+
}, {
97+
"id" : "1761316640794578",
98+
"location" : {
99+
"city" : "Sobral",
100+
"country" : "Brazil",
101+
"latitude" : -3.6977148166889,
102+
"longitude" : -40.347982048988,
103+
"state" : "CE",
104+
"street" : "North Shopping Sobral",
105+
"zip" : "62011-020"
106+
},
107+
"name" : "Hospital dos Iphones"
108+
}, {
109+
"id" : "332052750168526",
110+
"location" : {
111+
"city" : "Fortaleza",
112+
"country" : "Brazil",
113+
"latitude" : -3.7392181718505,
114+
"longitude" : -38.499867362003,
115+
"state" : "CE",
116+
"zip" : "60170-001"
117+
},
118+
"name" : "Hospital Geral do Exército de Fortaleza -HGeF. Hospital Militar"
119+
}, {
120+
"id" : "127909093951342",
121+
"location" : {
122+
"city" : "Fortaleza",
123+
"country" : "Brazil",
124+
"latitude" : -3.7344389226332,
125+
"longitude" : -38.531131765688,
126+
"state" : "CE",
127+
"zip" : "60040-000"
128+
},
129+
"name" : "IJF-Instituto Dr José Frota-Frotão"
130+
}, {
131+
"id" : "377836699242343",
132+
"location" : {
133+
"city" : "Fortaleza",
134+
"country" : "Brazil",
135+
"latitude" : -3.7128965,
136+
"longitude" : -38.5691958,
137+
"state" : "CE",
138+
"street" : "Francisco Sa"
139+
},
140+
"name" : "Hospital Luis De França Francisco Sa"
141+
}, {
142+
"id" : "230584297461022",
143+
"location" : {
144+
"city" : "Fortaleza",
145+
"country" : "Brazil",
146+
"latitude" : -3.7737,
147+
"longitude" : -38.5748,
148+
"state" : "CE"
149+
},
150+
"name" : "Centro Cirúrgico Hospital Infantil Albert Sabin"
151+
}, {
152+
"id" : "349899081692118",
153+
"location" : {
154+
"city" : "Fortaleza",
155+
"country" : "Brazil",
156+
"latitude" : -3.7737,
157+
"longitude" : -38.5748,
158+
"state" : "CE",
159+
"zip" : "60710-300"
160+
},
161+
"name" : "Beleza de Mulher"
162+
}, {
163+
"id" : "396588720722019",
164+
"location" : {
165+
"city" : "Fortaleza",
166+
"country" : "Brazil",
167+
"latitude" : -3.7346586,
168+
"longitude" : -38.5310112,
169+
"state" : "CE",
170+
"street" : "centro De Fortaleza"
171+
},
172+
"name" : "Hospital Frotao Do Centro"
173+
}, {
174+
"id" : "683121051744954",
175+
"location" : {
176+
"city" : "Fortaleza",
177+
"country" : "Brazil",
178+
"latitude" : -3.73278,
179+
"longitude" : -38.52396,
180+
"state" : "CE",
181+
"street" : "Rua Pero Coelho Milagres",
182+
"zip" : "60140-100"
183+
},
184+
"name" : "Francisco Assis de Oliveira Produtos Hospitalares"
185+
} ]
186+
}
187+
}

rapagemFacebook/pesquisas/result_all_feedsHospital.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import facebook
2+
import requests
3+
import json
4+
5+
# connect banco
6+
from firebase import firebase
7+
firebase = firebase.FirebaseApplication('https://you_domin.firebaseio.com/')
8+
9+
# config facebookAPI
10+
access_token ="you_token"
11+
graph = facebook.GraphAPI(access_token)
12+
13+
# Variaveis
14+
pergunta = 'Hospital' # pesquisa por paginas com esse nome
15+
lgMapa = '-3.731862, -38.526669' # localização
16+
17+
18+
pages = graph.search(type='place',
19+
q=pergunta,
20+
center=lgMapa,
21+
fields="message,name,comments,created_time,location")
22+
23+
while(True):
24+
try:
25+
for page in pages['data']:
26+
print(page)
27+
# Tente fazer requisição se a proxima pagina existir
28+
pages=requests.get(pages['paging']['next']).json()
29+
30+
except KeyError:
31+
# Quando não existir mais paginas (['paging']['next']), quebre o loop
32+
# fim de loop
33+
break
34+
35+
filteReturn = pages['data']
36+
37+
# Armazenando as informações
38+
# Em arquivo
39+
directFile = 'pesquisas/'+pergunta+'.json'
40+
directDB = '/'+pergunta
41+
42+
with open( directFile, 'w') as fp:
43+
json.dump(filteReturn, fp)
44+
# Firebase
45+
firebase.post(directDB, filteReturn)
46+
47+
print ( 'ok...')
48+

rapagemFacebook/src/facebook-sdk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 410f5c5892acea0c7a45a5382abccb6b7c702d6d
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This file is placed here by pip to indicate the source was put
2+
here by pip.
3+
4+
Once this package is successfully installed this source code will be
5+
deleted (unless you remove this file).

seedmessagefacebook.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
token ="you_token"
2+
3+
4+
graph = facebook.GraphAPI(token)
5+
profile = graph.get_object("me")
6+
friends = graph.get_connections("me", "friends")
7+
graph.put_object("me", "feed", message="Chincungunha")

0 commit comments

Comments
 (0)