Exemplo n.º 1
0
    def fetchURL(self, url, headers=[]):
        sc = safeurl.SafeURL()
        if headers:
            newHeaders = []
            try:
                for header in json_decode(headers):
                    try:
                        header = header.split(":")
                        # pop the first item off in case there are multiple :
                        key = header.pop(0).strip()
                        val = ":".join(header).strip()
                        newHeaders.append("{0}: {1}".format(key, val))
                    # ignore if invalid format (lacks :)
                    except:
                        continue
            # ignore if not json
            except:
                print("ignoring custom headers")
            if newHeaders:
                sc._handle.setopt(pycurl.HTTPHEADER, newHeaders)

        res = requests.get(url)
        print(res.content)
        #res = sc.execute(url)
        return str(res.content)
Exemplo n.º 2
0
import safeurl
import sys

# Default
try:
    sc = safeurl.SafeURL()
    res = sc.execute("https://fin1te.net")
except:
    print "Unexpected error:", sys.exc_info()

# options
try:
    sc = safeurl.SafeURL()

    opt = safeurl.Options()
    opt.clearList("whitelist")
    opt.clearList("blacklist")
    opt.setList("whitelist", ["google.com", "youtube.com"], "domain")

    sc.setOptions(opt)
    res = sc.execute("http://www.youtube.com")
except:
    print "Unexpected error:", sys.exc_info()

# url
try:
    url = safeurl.Url.validateUrl("http://google.com", safeurl.Options())
except:
    print "Unexpected error:", sys.exc_info()

# redirects
Exemplo n.º 3
0
 def fetchURL(self, url):
     sc = safeurl.SafeURL()
     res = sc.execute(url)
     return res