예제 #1
0
파일: Spider.py 프로젝트: jhkoivis/dvelib
from SOAPpy import SOAPProxy
from SOAPpy import Types
import urllib2
import socket

# CONSTANTS
_url = 'http://api.google.com/search/beta2'
_namespace = 'urn:GoogleSearch'


# need to marshall into SOAP types
SOAP_FALSE = Types.booleanType(0)
SOAP_TRUE = Types.booleanType(1)

# Google search options
_license_key = 'Cu7YX75QFHLS3WD/7/4CO+GsI/jC69eb' 
_query = ""
_start = 0
_maxResults = 10
_filter = SOAP_FALSE
_restrict = ''
_safeSearch = SOAP_FALSE
_lang_restrict = ''

def googleSearch(title):
    '''
    It is the function of the application that make the request at google WS using
    getting the first url of response.
    
    @param title: the title of the article to serach for
    @return: the first url
예제 #2
0
except ImportError:
    #Edit Tom De Smedt, 2004
    #For now, just use the legacy SOAP.py, no warning.
    #warn( "SOAPpy not imported. Trying legacy SOAP.py.",
    #      DeprecationWarning )
    try:
        import SOAP
    except ImportError:
        raise RuntimeError("Unable to find SOAPpy or SOAP. Can't continue.\n")

#
# Constants that differ between the modules
#
if SOAPpy:
    false = Types.booleanType(0)
    true = Types.booleanType(1)
    structType = Types.structType
    faultType = Types.faultType
else:
    false = SOAP.booleanType(0)
    true = SOAP.booleanType(1)
    structType = SOAP.structType
    faultType = SOAP.faultType


#
# Get a SOAP Proxy object in the correct way for the module we're using
#
def getProxy(url, namespace, http_proxy):
    if SOAPpy:
예제 #3
0
        
except ImportError:
    #Edit Tom De Smedt, 2004
    #For now, just use the legacy SOAP.py, no warning.
    #warn( "SOAPpy not imported. Trying legacy SOAP.py.",
    #      DeprecationWarning )
    try:
        import SOAP
    except ImportError:
        raise RuntimeError( "Unable to find SOAPpy or SOAP. Can't continue.\n" )

#
# Constants that differ between the modules
#
if SOAPpy:
    false      = Types.booleanType(0)
    true       = Types.booleanType(1)
    structType = Types.structType
    faultType  = Types.faultType
else:
    false      = SOAP.booleanType(0)
    true       = SOAP.booleanType(1)
    structType = SOAP.structType
    faultType  = SOAP.faultType

#
# Get a SOAP Proxy object in the correct way for the module we're using
#
def getProxy( url, namespace, http_proxy ):    
    if SOAPpy:
        return SOAPProxy( url,
예제 #4
0
# using sipXconfig SOAP from Python - example
# submitted by Joey Korkames<*****@*****.**>

    sipx_host = 'sipxserver.example.com'

    from SOAPpy import WSDL
    from SOAPpy import URLopener
    from SOAPpy import Types

    # need to marshall into SOAP types
    SOAP_FALSE = Types.booleanType(0)
    SOAP_TRUE = Types.booleanType(1)

    #I've manually disabled HTTP auth in my sipxconfig installation (to debug other issues), so the auth here may not actually work in a stock sipx environment....
    sipx_auth = URLopener.URLopener(username='******',passwd='scrubscrub')

    sipx_namespace = 'urn:ConfigService'

    sipx_user_wsdl = 'http://' + sipx_host + '/sipxconfig/services/UserService?wsdl'
    sipx_user = WSDL.Proxy(sipx_auth.open(sipx_user_wsdl), namespace=sipx_namespace)

    sipx_phone_wsdl = 'http://' + sipx_host + '/sipxconfig/services/PhoneService?wsdl'
    sipx_phone = WSDL.Proxy(sipx_auth.open(sipx_phone_wsdl), namespace=sipx_namespace)

    #prints SOAP traffic to STDOUT
    #sipx_user.soapproxy.config.dumpSOAPOut = 1
    #sipx_user.soapproxy.config.dumpSOAPIn = 1
    #sipx_phone.soapproxy.config.dumpSOAPOut = 1
    #sipx_phone.soapproxy.config.dumpSOAPIn = 1