Creates a Product API interface

@param string $url Url to analyze
@return Product
3206
public function createProductAPI($url)
    {
        $api = new Product($url);
        if (!$this->getHttpClient()) {
            $this->setHttpClient();
        }
        if (!$this->getEntityFactory()) {
            $this->setEntityFactory();
        }
        return $api->registerDiffbot($this);
    }
883632
public function setApiUrl(string $apiUrl): Client
    {
        $this->apiUrl = $apiUrl;
        $this->setUris();

        return $this;
    }
1332544
private function adByUrl($url)
    {
        $content = $this->client->get($url)->getBody()->getContents();

        $adData = new AdCrawler(new Crawler(utf8_encode($content)), $url);

        return $adData->getAll();
    }
876263
public static function createFromBase64(Url $url)
    {
        $pieces = explode(';', $url->getContent(), 2);

        if ((count($pieces) !== 2) || (strpos($pieces[0], 'image/') === false) || (strpos($pieces[1], 'base64,') !== 0)) {
            return false;
        }

        if (($info = @getimagesizefromstring(base64_decode(substr($pieces[1], 7)))) !== false) {
            return new self(
                $url,
                $url,
                200,
                $info['mime'],
                [$info[0], $info[1]],
                [],
                []
            );
        }
    }
37535
private function createRequestSet(string $url): array
    {
        $httpMethodList = $this->configuration->getHttpMethodList();
        $userAgentSelection = $this->getUserAgentSelection();
        $referrer = $this->configuration->getReferrer();

        $requests = [];

        foreach ($userAgentSelection as $userAgent) {
            foreach ($httpMethodList as $methodIndex => $method) {
                $headers = [
                    'user-agent' => $userAgent,
                ];

                if (!empty($referrer)) {
                    $headers['referer'] = $referrer;
                }

                $requests[] = new Request($method, $url, $headers);
            }
        }

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

        return $this->loadHtml($response->getBody()->__toString(), $url);
    }
864063
public function check(string $url): LinkState
    {
        $response = null;

        try {
            $requests = $this->createRequestSet($url);

            foreach ($requests as $request) {
                $response = $this->getHttpResponse($request);

                if ($response->getStatusCode() === self::HTTP_STATUS_CODE_OK) {
                    return new LinkState(LinkState::TYPE_HTTP, $response->getStatusCode());
                }
            }
        } catch (\InvalidArgumentException $invalidArgumentException) {
            if (substr_count($invalidArgumentException->getMessage(), 'Unable to parse URI')) {
                return new LinkState(LinkState::TYPE_CURL, Configuration::CURL_MALFORMED_URL_CODE);
            }
        } catch (HttpConnectException $connectException) {
            $curlExceptionFactory = new CurlExceptionFactory();

            if ($curlExceptionFactory::isCurlException($connectException)) {
                $curlException = $curlExceptionFactory::fromConnectException($connectException);
                return new LinkState(LinkState::TYPE_CURL, $curlException->getCurlCode());
            }
        } catch (GuzzleException $guzzleException) {
            // Cannot happen
            return new LinkState(LinkState::TYPE_CURL, 0);
        }

        return new LinkState(LinkState::TYPE_HTTP, $response->getStatusCode());
    }
813140
public function setUrl($url)
    {
        $this->httpClientBuilder->removePlugin(AddHostPlugin::class);
        $this->httpClientBuilder->addPlugin(new AddHostPlugin(UriFactoryDiscovery::find()->createUri($url)));

        return $this;
    }
1219196
protected static function getGitLabClient($url)
    {
        if (null === static::$client || static::$client->getBaseUrl() !== $url) {
            static::$client = new Client(trim($url, '/').'/');
        }

        return static::$client;
    }
355905
protected function buildApiUrl($url)
    {
        $api = $this->options->isWPAPI() ? $this->options->apiPrefix() : '/wc-api/';

        return \rtrim($url, '/') . $api . $this->options->getVersion() . '/';
    }
1265572
public static function fromUrl($url)
    {
        $client = new GuzzleHttp\Client();
        $response = $client->get($url);
        $jsonData = json_decode($response->getBody(), true);
        $instance = new self($jsonData);
        return $instance;
    }
359590
public function expand($url)
    {
        try {
            return $this->driver->expand($url);
        } catch (BadResponseException $e) {
            throw new Exceptions\InvalidResponseException($e->getMessage());
        } catch (InvalidApiResponseException $e) {
            throw new Exceptions\InvalidResponseException($e->getMessage());
        }
    }
202708
public static function create($url, $token)
    {
        $plugins = [
            new Plugin\RedirectPlugin(),
            new Plugin\RetryPlugin(['retries' => 5]),
            new Plugin\DecoderPlugin(),
            new Plugin\ErrorPlugin(),
        ];

        if ($token) {
            $plugins[] = new Plugin\AuthenticationPlugin(new QueryParam([
                'api_key' => $token,
            ]));
        }

        $client        = new PluginClient(Discovery\HttpClientDiscovery::find(), $plugins);
        $streamFactory = Discovery\StreamFactoryDiscovery::find();
        $builder       = new MultipartStreamBuilder($streamFactory);

        return new HttpPlugHttpAdapterClient($client, $url, Discovery\MessageFactoryDiscovery::find(), $builder);
    }
52483
public function get($url)
    {
        $ch = curl_init($url);

        if ( ! ini_get('open_basedir')) {
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        }

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);

        $content = curl_exec($ch);
        if ($content === false) {
            // there was a problem
            $error = curl_error($ch);
            throw new CurlException('Error retrieving "'.$url.'" ('.$error.')');
        }

        return $content;
    }
1238307
public function get($url) {

        $curl = $this->_createCurlHandle();

        // Configure our cURL handle for our GET call
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER, true);
        curl_setopt($curl, CURLOPT_POST, 0);
        curl_setopt($curl, CURLOPT_URL, $url);

        // Perform our request and check the response
        $response = curl_exec($curl);
        $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        $this->logger->info("Request returned a $code response.");
        $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
        curl_close($curl);

        // Extract header information from the response
        $headers = [];
        $raw_headers = explode("\n", substr($response, 0, $header_size));
        array_shift($raw_headers);
        foreach ($raw_headers as $header) {
            if (!trim($header)) {
                continue;
            }
            $field = explode(": ", $header);
            $headers[array_shift($field)] = trim(implode(': ', $field));
        }

        // Low level debug output
        foreach ($headers as $header => $value) {
            $this->logger->debug($header . ': ' . $value);
        }
        $body = substr($response, $header_size);
        $this->logger->debug($body);

        // Check our result for unexpected errors
        switch ($code) {
            case 401:
                throw new InvalidCredentialsException("Invalid API key specified.");
            case 400:
                throw new RuntimeException("Bad request. Check the URL you specified for errors.");
            case 404:
                throw new RuntimeException("Unknown endpoint specified. Check the URL you specified for errors.");
            case 429:
                throw new RateLimitExceededException("Ratelimit reached. Please try again in {$headers['Retry-After']} seconds.");
            case 503:
                throw new RuntimeException("Service unavailable. It is possible that your client has been throttled.");
        }

        // Check for unexpected errors
        if ($code != 200 && $code != 204) {
            throw new RuntimeException("Remote server returned an unexpected response: $code");
        }

        $this->logger->info("Response size: " . strlen($body));

        return $body;
    }
1125400
private function createUrl(string $url): Url
    {
        $url = new Url($url);

        if ((new SchemeLess)->isSatisfiedBy($url)) {
            $url = $url->appendScheme(
                new Scheme($this->schemes[0] ?? 'http')
            );
        }

        return $url;
    }
520434
public static function tumblr(Url $url)
    {
        if (($value = $url->getQueryParameter('z'))) {
            return Url::create($value);
        }

        return $url;
    }