Loads HTML from webpage.

@param string $url The URL of the webpage
@param \FlameCore\Webtools\HttpClient $http The HttpClient instance to use
@return self
@throws \RuntimeException if the URL could not be loaded.
197039
public static function fromWeb($url, HttpClient $http = null)
    {
        $http = $http ?: new HttpClient();

        $request = $http->get($url);

        if (!$request->success) {
            throw new \RuntimeException(sprintf('The URL "%s" could not be loaded.', $url));
        }

        return new static($request->data);
    }
15787
public function loadUrl($url, $curl = false) {
        if ($curl) {
            $content = self::loadContent($url);
            if (empty($content)) {
                throw new Exception("Can't get content from " . $url);
            }
            $this->loadString($content);
        } else {
            $this->load_file($url);
        }
    }
400223
public function fetchUrl($url, $httpClient = null) {
        if ($httpClient == null) {
            $httpClient = new Maestrano_Net_HttpClient();
        }

        return $httpClient->get($url);
    }
808047
public function request($url)
    {
        $curlOpts = array_replace($this->curlOpts, [CURLOPT_URL => $url]);

        $ch = curl_init();
        foreach ($curlOpts as $opt => $optVal) {
            curl_setopt($ch, $opt, $optVal);
        }

        $resp = curl_exec($ch);
        $info = (object) curl_getinfo($ch);
        curl_close($ch);

        //Check response
        $httpCode = (string) $info->http_code;
        if ($httpCode{0} != '2') {
            $msg = sprintf('HTTP Request Failed (code %s): %s', $info->http_code, $resp);
            throw new HttpException($resp, $msg, $httpCode);
        } elseif (strlen(trim($resp)) == 0) {
            throw new HttpException($resp, 'HTTP Response Empty');
        }

        return $resp;
    }
802376
protected InputStream getStream(HttpClient httpClient, String url) {
        try {
            HttpEntity entity = get(httpClient, url);
            if (entity == null) return null;
            return entity.getContent();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
685378
public static function load( $url, $curlOptions = array() )
	{
		$reader	= new Net_Reader( $url );
		$reader->setUserAgent( self::$userAgent );
		$xml	= $reader->read( $curlOptions );
		$type	= explode( ";",$reader->getInfo( Net_CURL::INFO_CONTENT_TYPE ) );
		$type	= array_shift( $type );

		if( !in_array( $type, self::$mimeTypes ) )
			throw new Exception( 'URL "'.$url.'" is not an accepted XML File (MIME Type: '.$type.').' );

		$parser	= new XML_DOM_Parser();
		$tree	= $parser->parse( $xml );
		return $tree;
	}
400352
protected function read(Url $url)
    {
        /** @var Response $response */
        try {
            $response = $this->getHttpInvoker()->get((string) $url);
        } catch (RequestException $exception) {
            $code = 0;
            $message = null;
            if ($exception->getResponse()) {
                $code = $exception->getResponse()->getStatusCode();
                $message = $exception->getResponse()->getBody();
            }
            throw $this->convertStatusCode(
                $code,
                (string) $message,
                $exception
            );
        }

        return $response;
    }
976110
public function loadUrl($url)
    {
        // Fetch HTTP content using Guzzle
        $response = $this->client->get($url);

        return $this->loadHtml($response->getBody()->__toString(), $url);
    }
133843
protected function query($method, $url, array $parameters = null)
    {
        return $this->httpClient->query($method, $url, $parameters);
    }
670063
protected function getClient(): HttpClient
    {
        if ($this->_client == null) {
            $this->_client = new HttpClient(['base_uri' => $this->_endpoint]);
        }

        return $this->_client;
    }
437921
public function loadString($content, $url = null)
    {
        parent::loadString($content);

        //Let twig load the content by proxiing through the getSource() method.
        $this->_twig_template = $this->_twig->loadTemplate($content);

        //Push the template on the stack
        array_push($this->_stack, $url);
        return $this;
    }
1225396
public static function httpFileExistsWithCurl($url) {
        if (!extension_loaded('curl'))
            throw new \Exception('Curl extension not loaded try change your PHP configuration');
        return ($ch = curl_init($url)) ? @curl_close($ch) || true : false;
    }
513783
protected function callApi($url)
    {
        $url = $this->apiBaseUrl . $url;

        $options = array(
            'http' => array(
                'method' => 'POST',
                'header' => 'Content-Type: application/x-www-form-urlencoded',
                'ignore_errors' => true,
                'content' => http_build_query($this->parameters, '', '&')
            )
        );

        $context = stream_context_create($options);

        $fp = fopen($url, 'rb', false, $context);
        if (!$fp) {
            throw new RuntimeException(
                sprintf(
                    'Could not connect to NMA API URL %s',
                    var_export($url, true)
                ),
                500
            );
        }

        $res = stream_get_contents($fp);
        if ($res === false) {
            throw new RuntimeException(
                sprintf(
                    'Could not fetch data from NMA API URL %s',
                    var_export($url, true)
                ),
                500
            );
        }

        $xml = simplexml_load_string($res);
        if ($xml === null) {
            throw new RuntimeException(
                sprintf(
                    'Could not decode NMA API response for URL %s as XML. ' .
                    'Response was: %s',
                    var_export($url, true),
                    var_export($res, true)
                ),
                500
            );
        }

        return $this->processXmlReturn($xml);
    }
801986
public function loadFromUrl(string $url, array $options = [], CurlInterface $curl = null): Dom
    {
        if (is_null($curl)) {
            // use the default curl interface
            $curl = new Curl;
        }
        $content = $curl->get($url);

        return $this->loadStr($content, $options);
    }
1074875
public static function load($url, $user = null, $pass = null)
	{
		$xml = self::loadXml($url, $user, $pass);
		if ($xml->channel) {
			return self::fromRss($xml);
		} else {
			return self::fromAtom($xml);
		}
	}
221672
public function loadFromUrl(string $url, array $header = []): JWKSet
    {
        $content = $this->getContent($url, $header);
        $data = $this->jsonConverter->decode($content);
        if (!\is_array($data)) {
            throw new \RuntimeException('Invalid content.');
        }

        return JWKSet::createFromKeyData($data);
    }
1048346
public function load(UriInterface $url = null)
    {
        $errMsg = sprintf('%s not supported method %s', ArrayConfiguration::class, __FUNCTION__);
        throw new Exception\MethodNotSupportedException($errMsg);
    }