Skip to content

Instantly share code, notes, and snippets.

@spacebit-official
Last active November 17, 2017 00:46
Show Gist options
  • Save spacebit-official/9f40673e3929884bbaba7e841e11bd3e to your computer and use it in GitHub Desktop.
Save spacebit-official/9f40673e3929884bbaba7e841e11bd3e to your computer and use it in GitHub Desktop.
regParse
<?
//парсинг с помощью регулярных выражений
$url = 'http:///';
$file = file_get_contents($url);
$pattern = '#<table class="rates-table-nbrb".+?</table>#s';
preg_match($pattern, $file, $matches);
print_r($matches);
#<body.+>(.*?)</body>#su //с учетом атрибутов
#<div[^>]+?id\s*?=\s*?["\']content["\'][^>]*?>(.+?)</div>#su
#<div[^>]+?id\s*?=\s*?(["\'])content\1[^>]*?>(.+?)</div>#su //первая ковычка ложится в карман
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment