Ejemplo n.º 1
0
#! /usr/bin/env python

import logging
from downpour import logger
from downpour.test import run, host
from downpour.test import ExpectRequest
from downpour.test import ExamineRequest
from downpour import BaseFetcher, BaseRequest

logger.setLevel(logging.CRITICAL)

fetcher = BaseFetcher(stopWhenDone=True)

# Try a plain-and-simple request
fetcher.push(
    ExpectRequest('200 Test',
                  host + 'asis/ok.asis',
                  expectHeaders={
                      'content-type': ['text/html'],
                      'content-length': ['11']
                  },
                  expectStatus=('HTTP/1.1', '200', 'OK'),
                  expectURL=host + 'asis/ok.asis',
                  expectSuccess='Hello world'))

# Try a redirect request, making sure we get
# every url we expect to get.
fetcher.push(
    ExpectRequest(
        '301 Redirect Test',
        host + 'asis/301_to_ok.asis',
Ejemplo n.º 2
0
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# 
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

from downpour import BaseRequest, BaseFetcher, logger
import logging

logger.setLevel(logging.DEBUG)

# Read in a set of urls to fetch
with file('urls.txt') as f:
	reqs = [BaseRequest(u) for u in f.read().strip().split('\n')]

# Now start it!
BaseFetcher(100, reqs).start()