-
Notifications
You must be signed in to change notification settings - Fork 10
/
people.py
33 lines (26 loc) · 832 Bytes
/
people.py
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
from twittercrawler.crawlers import PeopleCrawler
from twittercrawler.data_io import FileWriter, SocketWriter, FileReader
# prepare writers
keys = ["name","location","description"]
file_path = "people_results.txt"
fw = FileWriter(file_path, clear=True, include_mask=keys)
sw = SocketWriter(7000, include_mask=keys)
# execute this command in a bash console to continue: telnet localhost 7000
# initialize
people = PeopleCrawler(limit=5)
people.authenticate("../api_key.json")
people.connect_output([fw, sw])
# query
search_params = {
"q":"data scientist AND phd student",
}
people.set_search_arguments(search_args=search_params)
# run search
page, cnt = people.search()
print(page, cnt)
# close
people.close()
#load results
results_df = FileReader(file_path).read()
print("Hits:", len(results_df))
print(results_df.loc[0])