handler.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:JSParser 作者: nahamsec 项目源码 文件源码
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 = sc.execute(url)
        return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号