How to recover data from a page

Asked

Viewed 106 times

-3

Good afternoon, could anyone help me on how I could recover data from that page with php? www.boline.com.br/test.php

I know you need to use regular expressions to separate the data, but I don’t know how to do it.

  • What data is this? It would be interesting to exemplify with a line, how do you want it to separate.

  • If I understand correctly, your link is mere copy here, confirms?: http://www.netsorte.com.br/resultado_exportado/ResultadosMS.con Here it is much easier to catch, as it has no headers or anything, only the lines. Just use the explode PHP and the result is ready.

1 answer

1

You don’t necessarily need regex for that, you can go blowing up and getting the data.

for example, you can take all the data separated by space:

 $dados = explode("\n", file_get_contents('www.boline.com.br/teste.php'));

Ai can iterate this result and make new explodes ;)

Regex:

preg_match_all('~([0-9]{4})=([0-9]{2}),([0-9]{2}),([0-9]{2}),([0-9]{2}),([0-9]{2}),([0-9]{2})~', file_get_contents('www.boline.com.br/teste.php'), $dados);

There you will have :

0001=41,05,04,52,30,33

$dados[1][0] = 0001
$dados[1][1] = 41
$dados[1][2] = 05
$dados[1][3] = 04
$dados[1][4] = 52
$dados[1][5] = 30
$dados[1][6] = 33
  • In this case, since it is a possibly third content, how much memory will it use? The best solution is to break 1 time with explode the spaces and then use Generator to parse the rest, as I do not know the version of our friend’s php, I gave only two options

Browser other questions tagged

You are not signed in. Login or sign up in order to post.