Skip to content

Commit

Permalink
sample info
Browse files Browse the repository at this point in the history
  • Loading branch information
mapmeld committed May 30, 2016
1 parent 5bbcfff commit d57ab62
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
22 changes: 22 additions & 0 deletions sample-graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from lxml import html
import requests
from py2neo import Graph, Node, Relationship

g = Graph(user="neo4j", password="Swift")
tx = g.begin()

a = Node("Person", name="Alice")
tx.create(a)

b = Node("Person", name="Bob")
tx.create(b)

c = Relationship(a, "KNOWS", b, order=1)
tx.create(c)

tx.commit()

page = requests.get('http://moma.org/collection/works/2')
tree = html.fromstring(page.content)

print(len(tree.cssselect('div')))
15 changes: 4 additions & 11 deletions scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,13 @@
from py2neo import Graph, Node, Relationship

g = Graph(user="neo4j", password="Swift")

tx = g.begin()

a = Node("Person", name="Alice")
tx.create(a)
page = requests.get('http://moma.org/collection/works/2')
tree = html.fromstring(page.content)

b = Node("Person", name="Bob")
tx.create(b)
tree.cssselect('div')

c = Relationship(a, "KNOWS", b, order=1)
tx.create(c)

tx.commit()

page = requests.get('http://moma.org/collection/works/2')
tree = html.fromstring(page.content)

print(len(tree.cssselect('div')))

0 comments on commit d57ab62

Please sign in to comment.