-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fork of code from ScraperWiki at https://classic.scraperwiki.com/scra…
- Loading branch information
0 parents
commit d0e3e58
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Ignore output of scraper | ||
data.sqlite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#! /usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
from bs4 import BeautifulSoup | ||
import sys | ||
import requests | ||
|
||
results = {} | ||
|
||
companies = [ 'google', 'microsoft'] | ||
|
||
for company in companies: | ||
url = "http://www.linkedin.com/company/{}".format(company) | ||
raw = requests.get(url).content | ||
|
||
soup = BeautifulSoup(raw) | ||
|
||
node = soup.find(attrs = {"class" : "grid-f"}) | ||
|
||
if node!=None: | ||
info = node.find(attrs = {"class" : "basic-info"}) | ||
titles = [item.get_text(strip=True) for item in info.findAll("dt")] | ||
data = [item.get_text(strip=True) for item in info.findAll("dd")] | ||
output = dict(zip(titles,data)) | ||
else: | ||
output = {} | ||
|
||
output['company'] = company | ||
results[company] = output | ||
|
||
import random, time | ||
sleep_time = random.uniform(5,10) | ||
time.sleep(sleep_time) | ||
|
||
import scraperwiki | ||
scraperwiki.sql.save(['company'], results.values()) | ||
|
||
#import json | ||
#print json.dumps(results, indent=2) |