def write_html(data, domain, word_occurrence, filename): user_counter = 0 for d in data: for k, v in d.items(): user_counter += 1 filename = filename + '.html' with open(filename, 'w') as f: title = 'Linky: % s' % domain f.write(html.header(title)) headers = [ 'picture', 'fullname', 'firstname', 'middlename', 'surname', 'email', 'current role', 'current company' ] f.write(html.h3_span(['Users', user_counter])) f.write(html.p('Click the users image to view their LinkedIn!')) f.write(html.table_head(headers)) for d in data: for k, v in d.items(): fullname = k profile_url = v[0] picture = v[1] if picture == None: picture = False firstname = v[2] middlename = v[3] surname = v[4] email = v[5] current_role = v[6] current_company = v[7] f.write('<tr>\n') f.write(html.table_picture(profile_url, picture)) f.write(html.table_entry(fullname)) f.write(html.table_entry(firstname)) f.write(html.table_entry(middlename)) f.write(html.table_entry(surname)) f.write(html.table_entry(email)) f.write(html.table_entry(current_role)) f.write(html.table_entry(current_company)) f.write('</tr>\n') f.write('</tbody>\n') f.write('</table>\n') f.write(html.h3('Top roles')) f.write( html. p('The following table shows the most common roles within the designated organisation.\nRunning this tool again with these top 3 results as keywords will result in more specific data as the api data extraction only pulls 1000 results.' )) f.write(html.table_head(['Role', 'Count'])) for role, count in word_occurrence.items(): f.write('<tr>\n') f.write(html.table_entry(role)) f.write(html.table_entry(count)) f.write('</tr>\n') f.write('</tbody>\n') f.write('</table>\n') f.write(html.footer())
def write_html(users, data, job_role_count, filename): domain = data.domain validation = data.validation user_counter = 0 for user in users: user_counter += 1 filename = filename + '.html' with open(filename, 'w') as f: title = 'Linky: % s' % domain f.write(html.header(title)) if validation != None: headers = [ 'picture', 'fullname', 'firstname', 'middlename', 'surname', 'email', 'email validation', 'current role', 'current company' ] else: headers = [ 'picture', 'fullname', 'firstname', 'middlename', 'surname', 'email', 'current role', 'current company' ] f.write(html.h3_span(['User Count', user_counter])) f.write(html.p('Click the users image to view their LinkedIn!')) f.write(html.input_box()) f.write(html.table_head(headers)) for user in users: fullname = user.fullname profile_url = user.profile_url picture = user.picture if picture == None: picture = False firstname = user.firstname middlename = user.middlename surname = user.surname email = user.email current_role = user.current_role current_company = user.current_company f.write('<tr>\n') f.write(html.table_picture(profile_url, picture)) f.write(html.table_entry(fullname)) f.write(html.table_entry(firstname)) f.write(html.table_entry(middlename)) f.write(html.table_entry(surname)) f.write(html.table_entry(email)) if validation != None: validated = user.validated if validated == None: f.write(html.table_entry('Unable to validate')) else: if validated == True: try: f.write( html.table_entry('Got creds: %s') % validated[1]) except: f.write(html.table_entry(str(validated))) else: f.write(html.table_entry(str(validated))) f.write(html.table_entry(current_role)) f.write(html.table_entry(current_company)) f.write('</tr>\n') f.write('</tbody>\n') f.write('</table>\n') f.write(html.h3('Top roles')) f.write( html. p('The following table shows the most common roles within the designated organisation.\nRunning this tool again with these top 3 results as keywords will result in more specific data as the api data extraction only pulls 1000 results.' )) f.write(html.table_head(['Role', 'Count'])) for role, count in job_role_count.items(): f.write('<tr>\n') f.write(html.table_entry(role)) f.write(html.table_entry(count)) f.write('</tr>\n') f.write('</tbody>\n') f.write('</table>\n') f.write(html.footer())