Home

txCollecta

txCollecta provides a simple wrapper around the Collecta HTTP API.

All client queries return Twisted Deferreds and are meant to be used within the Twisted framework. Successful queries will callback with a modeled object based on a feedparser dict.

DOCUMENTATION

Documentation is located in the /docs directory

txCollecta/docs/html/index.html

To build the Sphinx docs from txCollecta/docs/src/

$ make html

REQUIREMENTS

To build docs:

TODO

The current client implements most of the Collecta HTTP API. See TODO for details.

TESTS

$ trial txcollecta.tests 

EXAMPLE APP

An example twisted.web app allows the user to query Collecta and display results.

The API_KEY in examples/simple_web.tac needs to be set prior to use.

$ twistd -noy examples/simple_web.tac

SAMPLE USAGE

from txcollecta.client import CollectaClient

API_KEY = '12345678901234567890'
c = CollectaClient(API_KEY)

# Unparsed results
result = c.search('"Sports Team"')
def parseAtom(result):
    # diy Atom parsing goes here
    print result # punt!
result.addCallback(parseAtom).addErrback(log.err)

# Parsed dict-like object returned from feedparser
parsed = c.getParsed('"meaningless gossip"')
def processParsed(result):
    print result
parsed.addCallback(processParsed)

# Shortcuts exist for specifying desired categories (Stories, Comments, Updates, Photos, Videos)
stories = c.getStories(query='Individual Search Terms OR "Search Term"')
def processStories(result):
    for story in result.stories:
        print story.title, story.links
stories.addCallback(processStories)

photos = c.getPhotos(query='"attractive individuals"')
def processPhotos(result):
    # naive demo; may destroy everything!
    for idx, photo in enumerate(result.photos.enclosures):
        fname = path.basename(urlparse(photo.href).path)
        d = twisted.web.client.downloadPage(photo.href, fname)
        # Add callback/errback for when file is downloaded and saved to disk
        d.addCallback(lambda _: pass)
        d.addErrback(log.err)
photos.addCallback(processPhotos).addErrback(log.err)

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.