Esempio n. 1
0
def getContent_GET(url, param, injection, txheaders):
    global log
    """
		Get the content of the url by GET method
	"""
    newUrl = url
    ret = None
    if url.find('?') < 0:
        if url[len(url) - 1] != '/' and not allowedExtensions(url):
            url += '/'
        newUrl = url + '?' + param + '=' + single_urlencode(str(injection))
    else:
        newUrl = url + '&' + param + '=' + single_urlencode(str(injection))
    try:
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
        urllib2.install_opener(opener)
        log <= (newUrl)
        context = ssl._create_unverified_context()
        req = Request(newUrl, None, txheaders)  # create a request object
        ret = urlopen(
            req, context=context)  # and open it to return a handle on the url
    except HTTPError, e:
        log <= ('The server couldn\'t fulfill the request.')
        log <= ('Error code: %s' % e.code)
        return None
Esempio n. 2
0
def getContentDirectURL_GET(url, string):
    global log

    ret = ""
    try:
        if len(string) > 0:
            if url[len(url) - 1] != '/' and url.find(
                    '?') < 0 and not allowedExtensions(url):
                url += '/'
            url = url + "?" + (string)
        opener = urllib.request.build_opener(
            urllib.request.HTTPCookieProcessor(cj))
        urllib.request.install_opener(opener)
        log <= (url)
        req = Request(url, None, txheaders)
        ret = urllib.request.urlopen(req)
    except HTTPError as e:
        log <= ('The server could not fulfill the request.')
        log <= ('Error code: %s' % e.code)
        return None
    except URLError as e:
        log <= ('We failed to reach a server.')
        log <= ('Reason: %s' % e.reason)
        return None
    except IOError:
        log <= ("Cannot open: %s" % url)
        return None
    return ret
Esempio n. 3
0
def getContent_GET(url, param, injection):
    global log

    newUrl = url
    ret = None
    if url.find('?') < 0:
        if url[len(url) - 1] != '/' and not allowedExtensions(url):
            url += '/'
        newUrl = url + '?' + param + '=' + single_urlencode(str(injection))
    else:
        newUrl = url + '&' + param + '=' + single_urlencode(str(injection))
    try:
        opener = urllib.request.build_opener(
            urllib.request.HTTPCookieProcessor(cj))
        urllib.request.install_opener(opener)
        log <= (newUrl)
        req = Request(newUrl, None, txheaders)
        ret = urllib.request.urlopen(req)
        ret = urllib.request.urlopen(req)
    except HTTPError as e:
        log <= ('The server could not fulfill the request.')
        log <= ('Error code: %s' % e.code)
        return None
    except URLError as e:
        log <= ('We failed to reach a server.')
        log <= ('Reason: %s' % e.reason)
        return None
    except IOError:
        log <= ("Cannot open: %s" % url)
        return None
    return ret
Esempio n. 4
0
def getContent_GET(url,param,injection):
	global log
	"""
		Get the content of the url by GET method
	"""
	newUrl = url
	ret = None
	if url.find('?') < 0:
		if url[len(url)-1] != '/' and not allowedExtensions(url):
			url += '/'
		newUrl = url + '?' + param + '=' + single_urlencode(str(injection))
	else:
		newUrl = url + '&' + param + '=' + single_urlencode(str(injection))
	try:
		print "skg new url ",newUrl
		opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
		urllib2.install_opener(opener)
		log <= ( newUrl)
		req = Request(newUrl, None, txheaders) # create a request object
		ret = urlopen(req)		       # and open it to return a handle on the url
		ret = urlopen(req)		       # and open it to return a handle on the url
	except HTTPError, e:
		log <= ( 'The server couldn\'t fulfill the request.')
		log <= ( 'Error code: %s' % e.code)
		return None
def getContentDirectURL_GET(url, string):
	global log
	"""
		Get the content of the url by GET method
	"""
	ret = ""
	try:
		if len(string) > 0:
			if url[len(url)-1] != '/' and url.find('?') < 0  and not allowedExtensions(url):
				url += '/'
			url = url + "?" + (string)
		opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
		urllib2.install_opener(opener)
		log <= ( url)
		req = Request(url, None, txheaders) # create a request object
		ret = urlopen(req)                     # and open it to return a handle on the url
	except HTTPError, e:
		log <= ( 'The server couldn\'t fulfill the request.')
		log <= ( 'Error code: %s' % e.code)
		return None
Esempio n. 6
0
def getContentDirectURL_GET(url, string):
	global log
	"""
		Get the content of the url by GET method
	"""
	ret = ""
	try:
		if len(string) > 0:
			if url[len(url)-1] != '/' and url.find('?') < 0  and not allowedExtensions(url):
				url += '/'
			url = url + "?" + (string)
		opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
		urllib2.install_opener(opener)
		log <= ( url)
		req = Request(url, None, txheaders) # create a request object
		ret = urlopen(req)                     # and open it to return a handle on the url
	except HTTPError, e:
		log <= ( 'The server couldn\'t fulfill the request.')
		log <= ( 'Error code: %s' % e.code)
		return None
def getContentDirectURL_GET(url, string, txheaders):
    global log
    """
		Get the content of the url by GET method
	"""
    ret = ""
    try:
        if len(string) > 0:
            if url[len(url) - 1] != "/" and url.find("?") < 0 and not allowedExtensions(url):
                url += "/"
            url = url + "?" + (string)
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
        urllib2.install_opener(opener)
        log <= (url)
        context = ssl._create_unverified_context()
        req = Request(url, None, txheaders)  # create a request object
        ret = urlopen(req, context=context)  # and open it to return a handle on the url
    except HTTPError, e:
        log <= ("The server couldn't fulfill the request.")
        log <= ("Error code: %s" % e.code)
        return None
def getContent_GET(url, param, injection, txheaders):
    global log
    """
		Get the content of the url by GET method
	"""
    newUrl = url
    ret = None
    if url.find("?") < 0:
        if url[len(url) - 1] != "/" and not allowedExtensions(url):
            url += "/"
        newUrl = url + "?" + param + "=" + single_urlencode(str(injection))
    else:
        newUrl = url + "&" + param + "=" + single_urlencode(str(injection))
    try:
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
        urllib2.install_opener(opener)
        log <= (newUrl)
        context = ssl._create_unverified_context()
        req = Request(newUrl, None, txheaders)  # create a request object
        ret = urlopen(req, context=context)  # and open it to return a handle on the url
    except HTTPError, e:
        log <= ("The server couldn't fulfill the request.")
        log <= ("Error code: %s" % e.code)
        return None