Example #1
0
def enqueue(subspider, spider):
    url = settings['SUBSPIDER_DESTINATION']
    spider_args = settings['SUBSPIDER_DEFAULTS'].copy()
    spider_args.update(subspider.get_members())
    spider_args['spider'] = subspider.spider

    error = ''
    message = ''

    try:
        response = urlpost(url, data=urlencode(spider_args))
        status = response.getcode()

        if status!= 200:
            error += 'response status %s for %s'%(status, url)
        else:
            json = loads(''.join(response.readlines()))
            message += '200 OK: "%s" for "%s"'%(json, url)
            
    except IOError, e:
        error += '`%s` at %s'%(e, url)
Example #2
0
 def post(self, url, data={}):
     resource = urlpost(url, urlencode(data) if data else None)
     return ''.join(resource.readlines()) \
                 if resource.getcode()==200 \
                 else resource.getcode()