Beispiel #1
0
class YellowPagesListItem(Resource):
    name = attr("h3.business-name a")
    url = attr("h3.business-name a", attribute='href')

    @property
    def details(self):
        return YellowPage(self.url)
Beispiel #2
0
class YellowPage(Resource):
    phone = attr("p.phone")
    street = attr("p.street-address")
    citystate = attr("p.city-state")

    @property
    def address(self):
        return self.street + " " + self.citystate
Beispiel #3
0
class YellowPage(Resource):
    phone = attr("p.phone strong")
    street = attr("span.street-address")
    city = attr("span.locality")
    state = attr("span.region")
    zip = attr("span.postal-code")

    @property
    def address(self):
        return " ".join([self.street, self.city, self.state, self.zip])
Beispiel #4
0
class HackerNews(Resource):
    titles = attr("table table:nth-of-type(2) tr td.title a", all=True)
    points = attr("table table:nth-of-type(2) tr td.subtext span", all=True)
    comments = attr(["table table:nth-of-type(2) tr td.subtext", "a:nth-of-type(2)"], all=True)

    def __init__(self):
        Resource.__init__(self, "http://news.ycombinator.com")

    @property
    def posts(self):
        posts = zip(self.titles, self.points, self.comments)
        return [ Post(t, c, p) for t, p, c in posts ]