Skip to content

Commit b341821

Browse files
authored
Update scraper.py
1 parent ca85bad commit b341821

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

scraper.py

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
# This is a template for a Python scraper on morph.io (https://morph.io)
2-
# including some code snippets below that you should find helpful
1+
import scraperwiki
2+
import csv
3+
data = scraperwiki.scrape('https://www.sos.state.co.us/pubs/charities/reports/2016/tables/Table2-PaidSolicitorSummary2016.csv')
4+
5+
reader = csv.DictReader(data.splitlines())
6+
7+
for row in reader:
8+
for key, value in row.iteritems():
9+
print key
310

4-
# import scraperwiki
5-
# import lxml.html
6-
#
7-
# # Read in a page
8-
# html = scraperwiki.scrape("http://foo.com")
9-
#
10-
# # Find something on the page using css selectors
11-
# root = lxml.html.fromstring(html)
12-
# root.cssselect("div[align='left']")
13-
#
14-
# # Write out to the sqlite database using scraperwiki library
15-
# scraperwiki.sqlite.save(unique_keys=['name'], data={"name": "susan", "occupation": "software developer"})
16-
#
17-
# # An arbitrary query against the database
18-
# scraperwiki.sql.select("* from data where 'name'='peter'")
19-
20-
# You don't have to do things with the ScraperWiki and lxml libraries.
21-
# You can use whatever libraries you want: https://morph.io/documentation/python
22-
# All that matters is that your final data is written to an SQLite database
23-
# called "data.sqlite" in the current working directory which has at least a table
24-
# called "data".
11+
print row['Ref. No.']
12+
scraperwiki.sqlite.save(['Ref. No.'], row)

0 commit comments

Comments
 (0)