All systems operational HTTP · HTTPS · SOCKS5 Global network
Documentation home Quickstart Engineering guides Code examples Global network Pricing Solutions overview Custom proxy pools Managed data scraping Contact Console
CODE EXAMPLE

Crawl and parse pages through LundProxy with PHP cURL.

Crawl and parse pages through LundProxy with PHP cURL. This example uses Rotating Proxies as the default gateway and can be adapted by replacing endpoint and routing credentials.

LanguagePHP 8.2+FrameworkcURL + DOMXPathGatewayRotating ProxiesFilescrape.php
01
SETUP

Install the client and create a file.

Use a clean project environment and pin tested dependency versions for production. The example target is a public scraping sandbox.

InstallEnable the curl and dom extensions
02
CREDENTIALS

Load proxy secrets from the environment.

The proxy username is not the LundProxy website login. Copy the complete username and password generated for the selected proxy product.

PROXY_USER=user-pool-crawlerPROXY_PASS=your-secret
03
COMPLETE EXAMPLE

scrape.php

Copy the code into the named file, set credentials, and run it from the project environment.

<?php
$curl = curl_init("https://quotes.toscrape.com/");
curl_setopt_array($curl, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_PROXY => "proxy.lundproxy.com",
    CURLOPT_PROXYPORT => 36923,
    CURLOPT_PROXYUSERPWD =>
        getenv("PROXY_USER") . ":" . getenv("PROXY_PASS"),
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_FAILONERROR => true,
]);

$html = curl_exec($curl);
if ($html === false) {
    throw new RuntimeException(curl_error($curl));
}
curl_close($curl);

$document = new DOMDocument();
@$document->loadHTML($html);
$xpath = new DOMXPath($document);
echo $xpath->query('//*[contains(@class, "quote")]')->length . PHP_EOL;
04
WHAT THE EXAMPLE DOES

Keep the important behavior visible.

01Proxy credentials use the dedicated cURL option.
02Connect and total timeouts are separate.
03HTTP failures enter error handling.
04DOM parsing occurs only after a successful response.
05
PRODUCTION NOTES

Add workload-specific controls before scale.

A successful sandbox run proves integration, not production readiness.

Test representative targets, response sizes, routing policy, concurrency, retries, validation, and completion window. Collect only public data you are authorized to access.

06
EXAMPLE FAQ

cURL + DOMXPath questions.

Why not put credentials in the proxy URL?

CURLOPT_PROXYUSERPWD avoids URL parsing problems with special characters.

How do I use SOCKS5?

Set CURLOPT_PROXYTYPE to CURLPROXY_SOCKS5_HOSTNAME and use assigned SOCKS access details.

What extensions are required?

Enable cURL for requests and DOM for DOMDocument and DOMXPath.