Callback Functions

Using the callback functions, you can extend WP Web Scraper to do some advanced parsing. Simply put, callback functions will will parse and return your data. Callback functions can reside in functions.php of your child theme. Placing your callback functions here will make sure that these don’t get lost on upgrading your theme. On changing your theme, just change the child theme parent to the new upgraded theme.

There are two sets of callback functions:

callback_raw

The function name specified in ‘callback_raw’ argument will parse the scraped content in its most raw form. This function expects only one array (of strings) argument and is called before any parsing arguments are applied. The code within this function should process the input and return a parsed array of strings or a single string as an output.

callback

The function name specified in ‘callback’ argument will parse the scraped content in its processed form. This function expects only one string argument and is called after all parsing arguments are applied. The code within this function should process the input and return a parsed string as an output. Here’s an example.

Leave a Reply