#!/usr/bin/python
import time

from spacebrewInterface.spacebrew import Spacebrew

# Construct a brew by passing in its name and the server you
# want to connect to.
brew1 = Spacebrew("first brew",server="localhost")
# This brew will publish a string called "pub".
brew1.addPublisher("pub1","range")
brew1.addPublisher("pub2","boolean")
brew1.addPublisher("pub3")

# Construct a second brew, connecting to the same server.
brew2 = Spacebrew("second brew",server="localhost")
# This brew will subscribe to a string called "sub".
brew2.addSubscriber("sub1","range")
brew2.addSubscriber("sub2","boolean")
brew2.addSubscriber("sub3")

# For any subscriber, you can define any number of functions
# that will get called with the sent value when a message arrives.
# Here's a simple example of a function that recieves a value.
def example(value):
    print "Got",value,type(value)
# We call "subscribe" to associate a function with a subscriber.
brew2.subscribe("sub1",example)
brew2.subscribe("sub2",example)
brew2.subscribe("sub3",example)

# Calling start on a brew starts it running in a separate thread.
예제 #2
0
#!/usr/bin/python

import time
import locale
from spacebrewInterface.spacebrew import Spacebrew
from lxml.html import parse
from lxml.cssselect import CSSSelector

# configure the spacebrew client
name = "Casual Scraper"
server = "sandbox.spacebrew.cc"
brew = Spacebrew(name, server=server)
brew.addPublisher("image", "string")
print("Starting spacebrew");
brew.start()


base_urls = [
	"http://newyork.craigslist.org/search/aap?hasPic=1", 
	"http://philadelphia.craigslist.org/search/aap?hasPic=1", 
	"http://sfbay.craigslist.org/search/aap?hasPic=1"]
history = []
try:
	while 1:
		for base_url in base_urls:
			print "scraping %s" % base_url
			doc = parse(base_url).getroot()
			links = doc.cssselect('span.pl a')
			if links:
				for link in links:
					subdoc_url = link.get('href')
예제 #3
0
#!/usr/bin/python

import time
import locale
from spacebrewInterface.spacebrew import Spacebrew
from lxml.html import parse
from lxml.cssselect import CSSSelector

# configure the spacebrew client
name = "Casual Scraper"
server = "sandbox.spacebrew.cc"
brew = Spacebrew(name, server=server)
brew.addPublisher("tick", "string")
# brew.addSubscriber("incoming", "string")

# def handleString(value):
# 	print(value)

# brew.subscribe("incoming", handleString)

try:
    print ("Starting spacebrew")
    brew.start()

    base_urls = [
        "http://newyork.craigslist.org/cas/",
        "http://philadelphia.craigslist.org/cas/",
        "http://sfbay.craigslist.org/cas/",
    ]
    links = []
    while 1: