Main Content


Scrape numbers from web page



num = urlfilter(URL,target,numNumbers,direction) returns numNumbers of numbers that appear after or before the target string target, depending on the value of direction. Numbers with a decimal point are scanned as a single number. All other non numeric characters are treated as number separators.


collapse all

Retrieve the first number after the string 'Latitude / Longitude' on a specified web page.

url = '';
target= 'Latitude / Longitude';
num = urlfilter(url,target)
num =


Retrieve the first three numbers after the string 'Dow' on a specified web page.

url = '';
target = 'Dow';
nums = urlfilter(url,target,3)
nums =

   1.0e+04 *

    2.3568   -0.0535   -0.0002 

These numbers correspond to the present value of the Dow, the point change, and percentage change for the day, respectively.

Input Arguments

collapse all

URL to scrape numbers from, specified as a string.

Target in the specified URL to scrape data, specified as a string.

Numbers to read after target on the specified URL. specified as a numeric value. The algorithm continues grabbing numbers until the specified numNumbers are grabbed or the call reaches end of the file.

URL read direction, specified as a string value. Valid values are 'forward' or 'backward'. The read command reads in the specified direction, starting from the target string.

Output Arguments

collapse all

Target number or numbers, returned as a numeric value or vector. If no optional arguments are specified, the command returns the first number after the target string.