Browse Source

add index page

master
Sam 7 years ago
parent
commit
cebc33349d
3 changed files with 10468 additions and 10 deletions
  1. +10398
    -0
      index.html
  2. +12
    -10
      linked_in_scraper.py
  3. +58
    -0
      template.html

+ 10398
- 0
index.html
File diff suppressed because it is too large
View File


+ 12
- 10
linked_in_scraper.py View File

@ -4,6 +4,7 @@ import csv
import os
import requests
from bs4 import BeautifulSoup
from jinja2 import Template
import headers
@ -150,22 +151,23 @@ def clean_and_parse(datafile, outname):
json.dump(out, jsonfile, indent=2)
with open(outname + '.csv', 'w') as csvfile:
fieldnames = ['name', 'title', 'location', 'url']
fieldnames = list(out[0].keys())
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
for row in out:
writer.writerow({
'name': row['name'],
'title': row['title'],
'location': row['location'],
'url': row['linkedin']
})
writer.writerow(row)
with open('template.html', 'r') as templatefile:
template = Template(templatefile.read())
html = template.render(people=out)
with open('index.html', 'w') as htmlout:
htmlout.write(html)
if __name__ == '__main__':
ICE = '533534'
datafile = 'ice_raw.json'
# get_company(ICE, datafile)
# get_profiles(datafile)
# get_images(datafile)
get_company(ICE, datafile)
get_profiles(datafile)
get_images(datafile)
clean_and_parse(datafile, 'ice')

+ 58
- 0
template.html View File

@ -0,0 +1,58 @@
<html>
<head>
<title>ICE @ LinkedIn</title>
<style>
body, table {
font: 14px sans-serif;
}
#container {
max-width: 1100px;
margin: auto;
}
table {
border-collapse: collapse;
width: 100%;
}
th {
text-align: left;
}
td {
padding: 3px;
border: 1px solid #ccc;
}
img {
max-width: 50px;
display: block;
}
a {
color: #000;
}
</style>
</head>
<body>
<div id="container">
<h1>People on LinkedIn who work for ICE</h1>
<table>
<tr>
<th></th>
<th>Name</th>
<th>Title</th>
<th>Location</th>
</tr>
{% for p in people %}
<tr>
<td>
{% if p.img %}
<a href="{{p.linkedin}}"><img src="{{p.img}}"></a> {% endif %}
</td>
<td><a href="{{p.linkedin}}">{{p.name}}</a></td>
<td>{{p.title}}</td>
<td>{{p.location}}</td>
</tr>
{% endfor %}
</table>
</div>
</body>
</html>

Loading…
Cancel
Save