1
+ {
2
+ "metadata" : {
3
+ "name" : " " ,
4
+ "signature" : " sha256:2413b0f161069741f95c0f0fb0360cbd9e980b48c636aa3f01432d348a79c660"
5
+ },
6
+ "nbformat" : 3 ,
7
+ "nbformat_minor" : 0 ,
8
+ "worksheets" : [
9
+ {
10
+ "cells" : [
11
+ {
12
+ "cell_type" : " markdown" ,
13
+ "metadata" : {},
14
+ "source" : [
15
+ " # The Ushahidi Team Maker\n " ,
16
+ " \n " ,
17
+ " *Creating esprit de corps through random.shuffle().*\n " ,
18
+ " \n " ,
19
+ " **Operations:**\n " ,
20
+ " - Scrapes Ushahidi team page for names\n " ,
21
+ " - Randomly assigns people to groups\n " ,
22
+ " - Assigns an uberconference room\n " ,
23
+ " - Prints results"
24
+ ]
25
+ },
26
+ {
27
+ "cell_type" : " code" ,
28
+ "collapsed" : false ,
29
+ "input" : [
30
+ " # Import required modules\n " ,
31
+ " import requests\n " ,
32
+ " from bs4 import BeautifulSoup\n " ,
33
+ " import random"
34
+ ],
35
+ "language" : " python" ,
36
+ "metadata" : {},
37
+ "outputs" : [],
38
+ "prompt_number" : 1
39
+ },
40
+ {
41
+ "cell_type" : " code" ,
42
+ "collapsed" : false ,
43
+ "input" : [
44
+ " # Create a variable with the URL\n " ,
45
+ " url_names = 'http://www.ushahidi.com/mission/team/'\n " ,
46
+ " \n " ,
47
+ " # Scrape the HTML at the url\n " ,
48
+ " r_names = requests.get(url_names)\n " ,
49
+ " \n " ,
50
+ " # Turn the HTML into a Beautiful Soup object\n " ,
51
+ " soup_names = BeautifulSoup(r_names.text)"
52
+ ],
53
+ "language" : " python" ,
54
+ "metadata" : {},
55
+ "outputs" : [],
56
+ "prompt_number" : 2
57
+ },
58
+ {
59
+ "cell_type" : " code" ,
60
+ "collapsed" : false ,
61
+ "input" : [
62
+ " team = []"
63
+ ],
64
+ "language" : " python" ,
65
+ "metadata" : {},
66
+ "outputs" : [],
67
+ "prompt_number" : 3
68
+ },
69
+ {
70
+ "cell_type" : " code" ,
71
+ "collapsed" : false ,
72
+ "input" : [
73
+ " for item in soup_names.find_all({'h3'}): \n " ,
74
+ " team.append(item.string.strip())"
75
+ ],
76
+ "language" : " python" ,
77
+ "metadata" : {},
78
+ "outputs" : [],
79
+ "prompt_number" : 4
80
+ },
81
+ {
82
+ "cell_type" : " code" ,
83
+ "collapsed" : false ,
84
+ "input" : [
85
+ " def make_groups(l, n):\n " ,
86
+ " random.shuffle(l)\n " ,
87
+ " if n < 1:\n " ,
88
+ " n = 1\n " ,
89
+ " return [l[i:i + n] for i in range(0, len(l), n)]"
90
+ ],
91
+ "language" : " python" ,
92
+ "metadata" : {},
93
+ "outputs" : [],
94
+ "prompt_number" : 5
95
+ },
96
+ {
97
+ "cell_type" : " code" ,
98
+ "collapsed" : false ,
99
+ "input" : [
100
+ " groups = make_groups(team, 10)"
101
+ ],
102
+ "language" : " python" ,
103
+ "metadata" : {},
104
+ "outputs" : [],
105
+ "prompt_number" : 6
106
+ },
107
+ {
108
+ "cell_type" : " code" ,
109
+ "collapsed" : false ,
110
+ "input" : [
111
+ " rooms = ['https://www.uberconference.com/ushahidi', \n " ,
112
+ " 'https://www.uberconference.com/chrisalbon', \n " ,
113
+ " 'https://www.uberconference.com/natmanning',\n " ,
114
+ " 'https://www.uberconference.com/juliana',\n " ,
115
+ " 'https://www.uberconference.com/woody',\n " ,
116
+ " 'https://www.uberconference.com/brian']"
117
+ ],
118
+ "language" : " python" ,
119
+ "metadata" : {},
120
+ "outputs" : [],
121
+ "prompt_number" : 7
122
+ },
123
+ {
124
+ "cell_type" : " code" ,
125
+ "collapsed" : false ,
126
+ "input" : [
127
+ " n = 0\n " ,
128
+ " for item in groups:\n " ,
129
+ " print('Group #', n+1)\n " ,
130
+ " print('Room:', rooms[n])\n " ,
131
+ " print(sep='\\ n')\n " ,
132
+ " print(*item, sep='\\ n')\n " ,
133
+ " print(sep='\\ n')\n " ,
134
+ " n = n+1"
135
+ ],
136
+ "language" : " python" ,
137
+ "metadata" : {},
138
+ "outputs" : [
139
+ {
140
+ "output_type" : " stream" ,
141
+ "stream" : " stdout" ,
142
+ "text" : [
143
+ " Group # 1\n " ,
144
+ " Room: https://www.uberconference.com/ushahidi\n " ,
145
+ " \n " ,
146
+ " Juliana Rotich\n " ,
147
+ " Sara-Jayne Terp\n " ,
148
+ " Woody Gilk\n " ,
149
+ " David Kobia\n " ,
150
+ " Vidya Spandana\n " ,
151
+ " Angela Oduor\n " ,
152
+ " Jonathon Morgan\n " ,
153
+ " Ben Lieblich\n " ,
154
+ " Linda Kamau\n " ,
155
+ " Henry Addo\n " ,
156
+ " \n " ,
157
+ " Group # 2\n " ,
158
+ " Room: https://www.uberconference.com/chrisalbon\n " ,
159
+ " \n " ,
160
+ " Mathias Antonsson\n " ,
161
+ " Gregory Omondi\n " ,
162
+ " Chris Albon, Ph.D.\n " ,
163
+ " Rob Baker\n " ,
164
+ " Brian Herbert\n " ,
165
+ " Shadrock Roberts\n " ,
166
+ " Nathaniel Manning\n " ,
167
+ " Anarghya Vardhana\n " ,
168
+ " Limo Taboi\n " ,
169
+ " Sharon Rutto\n " ,
170
+ " \n " ,
171
+ " Group # 3\n " ,
172
+ " Room: https://www.uberconference.com/natmanning\n " ,
173
+ " \n " ,
174
+ " Sebastian Mitchell\n " ,
175
+ " Aurelia Moser\n " ,
176
+ " Robbie Mackay\n " ,
177
+ " Zack Halloran\n " ,
178
+ " Daudi Were\n " ,
179
+ " Jepchumba Thomas\n " ,
180
+ " Jon Shuler\n " ,
181
+ " Esther Ondigo\n " ,
182
+ " Seth Hall\n " ,
183
+ " \n "
184
+ ]
185
+ }
186
+ ],
187
+ "prompt_number" : 8
188
+ },
189
+ {
190
+ "cell_type" : " code" ,
191
+ "collapsed" : false ,
192
+ "input" : [],
193
+ "language" : " python" ,
194
+ "metadata" : {},
195
+ "outputs" : [],
196
+ "prompt_number" : 8
197
+ }
198
+ ],
199
+ "metadata" : {}
200
+ }
201
+ ]
202
+ }
0 commit comments