Getting started
Learn to use Oxylabs Custom Parser. On this page, you'll find comprehensive examples, tips, and details on what happens if parsing fails.
How to use Custom Parser
Scenario example
Parse the price of the first product listed on an e-commerce site, https://sandbox.oxylabs.io/products?q=super+mario:

There are three ways to create a parser. This page walks through the quickest one, OxyCopilot, and the other two are covered on their own pages:
Generate parsers with OxyCopilot
OxyCopilot lets you describe your needs in plain English to automatically create scrapers and parsers for a website. Learn the basics by following the steps outlined below and check out OxyCopilot documentation for more information.
Open the Web Scraper API Playground on our dashboard to access OxyCopilot.
Write the prompt
Explain the data you want to extract from a page. Make sure to be descriptive and provide the most important information. You can find prompt examples for popular websites in our OxyCopilot prompts library.
Paste the following prompt to extract the price of the first product:

Click the Generate instructions button to send your prompt.
Review parsed data and instructions
Once OxyCopilot finishes, you'll see the following window where parsed data is on the right-side:

If you want to make any adjustments, you can do so here. Modify the URL(s), refine the prompt, enable JavaScript rendering, or edit the parsing schema to suit your needs. When you update any fields in this window, you can rerun the request by selecting Start new request.
You may also view and directly edit the parsing instructions here:

Once you're happy with the result, Load instructions to continue.

Save the parser as a preset
You can easily save your parsing instructions as a parser preset. This lets you reuse the preset in OxyCopilot and with your API requests.
In the Web Scraper API Playground, you can optionally choose the user for which to save the preset. Once you're all set, simply click Save:

A pop-up will appear prompting you to name the preset and add an optional description:

Advanced usage
OxyCopilot is the quickest way to create a parser, but every step of it is also available directly through the API:
Generate parsing instructions via API – send a prompt or a JSON schema together with a few example URLs and receive ready-to-use instructions. See Generating parsing instructions via API.
Save and manage presets via API – create, update, list and delete parser presets, and enable self-healing. See Parser Presets.
Write parsing instructions manually – build your own extraction pipeline with XPath and CSS selectors. Start with How to write parsing instructions, then browse the Parsing instruction examples.
What happens if parsing fails when using Custom Parser
If Custom Parser cannot apply one of your instructions, the job still succeeds: the result carries parse_status_code 12005 (parsed with warnings) and a _warnings list describing which instruction failed and why. You are charged for such results.
For example, this request asks for a field whose XPath matches nothing on the page:
The price is parsed normally, the failing field is returned as null, with a warning:
To ignore a failing field instead of receiving a warning, see Parsing instruction examples › Error handling.
If Custom Parser encounters an exception and breaks during the parsing operation, it can return status codes 12002, 12006, and 12007. You will not be charged for these unexpected errors.
Instructions referencing a non-existent function are rejected upon submission and no job is created. The API returns an HTTP 400 error naming the missing function and its path: function not_a_real_fn is not defined.
Status codes
See our status codes outlined here.
Last updated
Was this helpful?



