Skip to content

Commit

Permalink
Update scraper.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zegor committed Jul 14, 2018
1 parent 08dd023 commit 50a7231
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions scraper.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# This is a template for a Python scraper on morph.io (https://morph.io)
# including some code snippets below that you should find helpful
# Python scraper on morph.io (https://morph.io)

# Import libraries
import scraperwiki
import lxml.html

# Read in a page
# Scrape source
html = scraperwiki.scrape("http://www.espn.com/nhl/statistics")

# Find something on the page using css selectors
# Parse HTML
root = lxml.html.fromstring(html)
elements = root.find_class("colhead")
print(elements[0].text_content())
print(elements[1].text_content())

# Print each element
for element in elements:
print(element)

# Write out to the sqlite database using scraperwiki library
# scraperwiki.sqlite.save(unique_keys=["column1"], data={"column1": column1}, table_name="data")
Expand Down

0 comments on commit 50a7231

Please sign in to comment.