Analyze given `url` and return output as JSON.
326650
def analyzer_api(url):
    
    response.content_type = JSON_MIME

    # handle cacheing
    ri = get_cached_or_new(url)

    try:

        if ri.is_old():
            logger.info("Running the analysis.")

            # forget the old one and create new request info - this prevents
            # conflict errors
            ri = get_cached_or_new(url, new=True)

            # run the processing
            ri.paralel_processing()

    except (requests.exceptions.Timeout, requests.ConnectionError) as e:
        error_msg = """
            Požadovanou stránku {url} nebylo možné stáhnout během {timeout}
            vteřin. Zkuste URL zadat s `www.`, či zkontrolovat funkčnost
            stránek.
            <span style="display: none">{message}</span>
        """
        error_msg = error_msg.format(
            url=url,
            timeout=REQUEST_TIMEOUT,
            message=str(e.message)
        )
        logger.error(error_msg)

        return {
            "status": False,
            "log": "",  # TODO: get real log
            "error": error_msg,
        }
    except Exception as e:
        error_msg = str(e.message) + "\n" + traceback.format_exc().strip()
        logger.error(error_msg)
        return {
            "status": False,
            "log": "ri.get_log()",
            "error": error_msg,
        }

    return {
        "status": True,
        "body": ri.to_dict(),
        "log": "ri.get_log()",
    }
69663
def read(url, **args):
    """"""
    info, data = url.path.split(',')
    info = data_re.search(info).groupdict()
    mediatype = info.setdefault('mediatype', 'text/plain;charset=US-ASCII')
    if ';' in mediatype:
        mimetype, params = mediatype.split(';', 1)
        params = [p.split('=') for p in params.split(';')]
        params = dict((k.strip(), v.strip()) for k, v in params)
    else:
        mimetype, params = mediatype, dict()
    data = base64.b64decode(data) if info['base64'] else urllib.unquote(data)
    return content_types.get(mimetype).parse(data, **params)
550398
def parse(url):
    """"""

    conf = {}

    url = urlparse.urlparse(url)
    qs = urlparse.parse_qs(url.query)

    # Remove query strings
    path = url.path[1:]
    path = path.split('?', 2)[0]

    # Update with environment configuration
    conf.update({
        'EMAIL_FILE_PATH': path,
        'EMAIL_HOST_USER': unquote(url.username),
        'EMAIL_HOST_PASSWORD': unquote(url.password),
        'EMAIL_HOST': url.hostname,
        'EMAIL_PORT': url.port,
        'EMAIL_USE_SSL': False,
        'EMAIL_USE_TLS': False,
    })

    if url.scheme in SCHEMES:
        conf['EMAIL_BACKEND'] = SCHEMES[url.scheme]

    # Set defaults for `smtp`
    if url.scheme == 'smtp':
        if not conf['EMAIL_HOST']:
            conf['EMAIL_HOST'] = 'localhost'
        if not conf['EMAIL_PORT']:
            conf['EMAIL_PORT'] = 25

    # Set defaults for `smtps`
    if url.scheme == 'smtps':
        warnings.warn(
            "`smpts` scheme will be deprecated in a future version,"
            " use `submission` instead",
            UserWarning,
        )
        conf['EMAIL_USE_TLS'] = True

    # Set defaults for `submission`/`submit`
    if url.scheme in ('submission', 'submit'):
        conf['EMAIL_USE_TLS'] = True
        if not conf['EMAIL_PORT']:
            conf['EMAIL_PORT'] = 587

    # Query args overwrite defaults
    if 'ssl' in qs and qs['ssl']:
        if qs['ssl'][0] in TRUTHY:
            conf['EMAIL_USE_SSL'] = True
            conf['EMAIL_USE_TLS'] = False
    elif 'tls' in qs and qs['tls']:
        if qs['tls'][0] in TRUTHY:
            conf['EMAIL_USE_SSL'] = False
            conf['EMAIL_USE_TLS'] = True

    # From addresses
    if '_server_email' in qs:
        conf['SERVER_EMAIL'] = qs['_server_email'][0]
    if '_default_from_email' in qs:
        conf['DEFAULT_FROM_EMAIL'] = qs['_default_from_email'][0]

    return conf
1087052
public static Analysis readAnalysis(final URL url) throws IOException {
        checkNotNull(url);
        try (BufferedReader reader = Resources.asCharSource(url, Charsets.UTF_8).openBufferedStream()) {
            return readAnalysis(reader);
        }
    }
1338326
def json_response(data, status=200):
    """"""
    from django.http import JsonResponse
    return JsonResponse(data=data, status=status, safe=isinstance(data, dict))
308041
def get_api_results(url)
      uri = URI.parse(url)
      puts "URL: #{url}" if self.verbose
      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = true

      request = Net::HTTP::Get.new(uri.request_uri)
      response = http.request(request)

      JSON.parse(response.body)
    end
943198
def download_as_json(url):
    
    try:
        return Response('application/json', request(url=url)).read()
    except HTTPError as err:
        raise ResponseException('application/json', err)
84590
def get_json_response(self, content, **kwargs):
        """"""

        # Don't care to return a django form or view in the response here.
        # Remove those from the context.
        if isinstance(content, dict):
            response_content = {k: deepcopy(v) for k, v in content.items()
                                if k not in ('form', 'view') or k in ('form', 'view')
                                and not isinstance(v, (Form, View))}
        else:
            response_content = content

        return HttpResponse(content=json.dumps(response_content),
                            content_type='application/json; charset=utf-8',
                            **kwargs)
447270
function json(url, callback) {
    return request(url, function(req) {
      if (req.responseText) callback(JSON.parse(req.responseText));
    }, "application/json");
  }
1081343
def get_json(self, path, watch=None):
        """"""
        data, _ = self.get(path, watch)
        return load_json(data) if data else None
967720
def analyze_link(url, absolute = nil)  # :nodoc:
    dir_long , sheet = url.split(/\#/)
    link_type = absolute ? (0x01 | absolute) : 0x0103

    if sheet
      link_type |= 0x08
      sheet_len  = [sheet.bytesize + 0x01].pack("V")
      sheet      = sheet.split('').join("\0") + "\0\0\0"
    else
      sheet_len   = ''
      sheet       = ''
    end

    [dir_long, link_type, sheet_len, sheet]
  end
962529
function queryStringToJSON(url) {
  if (url === '') {
    return '';
  }
  var pairs = (url).slice(0).split('&'), result = {};
  for (var idx in pairs) {
    var pair = pairs[idx].split('=');
    if (!!pair[0]) {
      result[pair[0].toLowerCase()] = decodeURIComponent(pair[1] || '');
    }
  }
  return result;
}
35782
def _get_data(url):
    """"""
    if urllib_parse.urlparse(url).scheme in ('http', 'https'):
        resp = urllib_request.urlopen(url)
        encoding = resp.headers.get('content-encoding', 'plain')
        data = resp.read()
        if encoding == 'plain':
            data = data.decode('utf-8')
        elif encoding == 'gzip':
            data = BytesIO(data)
            data = gzip.GzipFile(fileobj=data).read().decode('utf-8')
        else:
            raise RuntimeError('unknown encoding')
    else:
        with codecs.open(url, mode='r', encoding='utf-8') as fid:
            data = fid.read()

    return data
1188430
def get_content_json(request):
    """"""
    result = _get_content_json()

    resp = request.response
    resp.status = "200 OK"
    resp.content_type = 'application/json'
    resp.body = json.dumps(result)
    return result, resp
622650
def version(self):
        """"""
        return self.get_json(URL_VERSION.format(self._url), astext=True)
749053
def analyses():
    """"""
    per_page = int(request.args.get('per_page', 50))
    page = int(request.args.get('page', 1))
    query = store.analyses(status=request.args.get('status'),
                           query=request.args.get('query'),
                           is_visible=request.args.get('is_visible') == 'true' or None)

    query_page = query.paginate(page, per_page=per_page)
    data = []
    for analysis_obj in query_page.items:
        analysis_data = analysis_obj.to_dict()
        analysis_data['user'] = analysis_obj.user.to_dict() if analysis_obj.user else None
        analysis_data['failed_jobs'] = [job_obj.to_dict() for job_obj in analysis_obj.failed_jobs]
        data.append(analysis_data)

    return jsonify(analyses=data)
1129644
def as_json(self, path="", with_indent=False):
        
        if path not in self.top_level_links:
            raise StateError("Unknown path")

        return json.dumps(self.get_state_repr(path),
                          indent=4 if with_indent else None)