#1 Extraindo Dados de alguma Página da Internet Sex Ago 26, 2011 5:14 pm
Windows
Novato
A Extração de Dados de alguma page na Internet temperatura si tornado Comum OU talvez necessário dependendo da SUA necessidade. A Atividade de extrair Chama-SE Web demolição , Que VEM fazer Tela de demolição , Onde hum Programa Navega NAS Telas de Outro Sistema "emulando" um Operador e extrai Dados.
A Extração de Dados desen Semper observar o autor do site e dependendo, Recomendo pedir autorização Prévia pingos de EUA o Processo normalmente. Principalmente Que TODO Acesso à Internet e sites de São rastreáveis e hum Acesso Constante certamente suspeitas poderá Gerar.
Código não abaixo, Faço uma Busca da Página do php.net e extraio ALGUMAS Informações Como o Título e como fazer OPÇÕES Menu.
Nao tenho Como explicar OBJETIVO Como Que voce fara uma Leitura dos Dados. O PHP temperatura o Suporte uma varias OPÇÕES Como o file_get_contents, curl OU fopen fsocket ou. Não dei exemplo a abaixo Preferência AO stream_context_create e stream_get_contents
DESDE Que tiva O Primeiro Contato com uma los Programação 1981, tenho uma USADO Máxima Que Manuais Encontrei Nós do Unix Anos atrás Onde Dizia "Use a Força, Leia a fonte", Use uma Força, leia o Fonte. Penso Que hum parágrafo Programador, hum Código Diz Muito Mais Que Páginas e manual, entao, estou publicando o resumo de Como Fazer uma Coisa.
<Php?
error_reporting (E_ALL & ~ E_NOTICE);
$ sourceURL = 'http://php.net';
$ opts = array ('http' => array ('método' => 'GET'
, 'follow_location' => '1 '
, 'max_redirects' => '10 '
, 'ignore_errors' => '1 ')
);
$ context = stream_context_create ($ opts);
$ stream = fopen ($ sourceURL, 'r', false, o contexto $) ;
$ content = stream_get_contents ($ stream);
echo '<pre>';
/ / echo htmlentities ($ content);
echo '<hr /> Pega o conteudo do <title>';
preg_match_all ('% <title> ( ? P <titulo> título [^<]+)>% ', $ content, $ matches, PREG_OFFSET_CAPTURE);
foreach ($ matches [0] as $ chave => $ value) {
echo '<br /> < b> Titulo </ b> = ', $ matches [' titulo '] [$ key] [0];
}
echo '<hr /> Todos: <a href =';
preg_match_all ('% (? P <caption> [^<]+) a>% ', $ content, $ matches, PREG_OFFSET_CAPTURE?);
foreach ($ matches [0] como $ valor => $ key) {
echo '<br /> href </ b> =', $ matches ['href'] [$ key] [0];
echo '- <b> legenda </ b > = ', $ matches [' legenda '] [$ key] [0];
}
preg_match_all (?% <div id="headmenu"> (P <menu> div .*?)</%> s ', partidas $ content, $, PREG_OFFSET_CAPTURE);
'<hr /> Somente o MENU' echo;
echo '<br /> Menu </ b> =', htmlentities ($ menu = $ matches [menu] [0] [0]);
preg_match_all ('% <a href = "(P(? P <caption> [^<]+) um?>%', menu $, $ matches, PREG_OFFSET_CAPTURE);
'<hr /> Itens' echo;
foreach ($ matches [0] as $ chave => $ value) {
echo '<br /> href </ b> =', $ matches ['href'] [$ key] [0];
echo '- <b> legenda </ b> =', $ partidas ['legenda'] [$ key] [0];
}
fclose ($ stream);
Resultado da execução do Programa:
Pega o conteudo do <title>
Titulo = PHP: Hypertext Preprocessor
Todos: <a href =
href = downloads.php / - legenda = downloads
href = docs.php / - legenda = documentação
href = / faq.php - legenda = faq
href = support.php / - legenda = obter ajuda
href = / discussão lists.php - legenda listas de discussão =
href = licença / - legenda = licenças
href = http://wiki.php.net/ - legenda = wiki
href = http://bugs.php.net/ - legenda = relatórios erros
href = / sites.php - legenda = php.net locais
href = / links.php - legenda = links
href = / conferências / - legenda = conferências
href = / my.php - legenda = meu php.net
href = tut / . php - legenda = tutorial introdutório
href = / docs.php - legenda = manual
href = links.php / - legenda = seção de links
href = usage.php / - legenda = Netcraft Pesquisa
href = thanks.php / - legenda = Obrigado
Redes
href = http://www.servercentral.net/ - legenda = Servidor Central
href = http://www.hostedsolutions.com/ - legenda = Hosted Solutions
href = http://www.spry.com/ - legenda = Spry VPS Hosting
href = http://ez.no/ - legenda = eZ Systems
href = http://www.hit.no/ - legenda = HiT
href = http://www.osuosl.org - legenda = OSU Aberto Fonte Lab
href = http://www.yahoo.com/ - legenda = Yahoo!
Webhosting
href = http://www.redpill-linpro.com - legenda = Redpill
- legenda = Atom feed
href = http://qa.php.net/rc.php - legenda = Os candidatos Lançamento
href = / submeter-event.php - legenda = [add]
href = http://www.php.net / conferências / index.php # id2011-08-11-1 - legenda = ConFoo 2012
href = http://www.php.net/conferences/index.php # id2011-05-30-1 - legenda = PHP North West , 2011
href = http://qa.php.net/ - legenda = alpha release
href = / releases/NEWS_5_4_0_ alpha1.txt - legenda = NEWS
href = mailto: php-qa@lists.php.net - legenda de discussão = QA lista
href = https://bugs.php.net/ - legenda = bug PHP rastreador
href = http://windows.php.net/qa/ - legenda =
site do Windows QA
href = https://wiki.php.net / rfc / releaseprocess / - legenda = releaseprocess RFC
href = / download docs.php-
- legenda = ChangeLog
href = downloads.php / - legenda = downloads
- legenda = este script
href = / archive / index.php - caption = Arquivo de Notícias
href = / feed.atom - legenda = Atom
href ?. = / source.php url = index / php - legenda = fonte mostram
href = / créditos . php - legenda = créditos
href = / stats / - legenda = stats
href = / sitemap.php - legenda = sitemap
href = / contact.php - legenda = contato
href = / contact.php # anúncios - legenda = publicidade
href = / mirrors.php - legenda = sites espelho
href = / copyright.php - legenda = Copyright © 2001-2011 O Grupo PHP
href = / mirror.php - caption = Este espelho
href = http://developer.yahoo.com/ - legenda = Yahoo! Inc.
Somente MENU o
menu =
<a href="/docs.php"> documentação </ a> |
<a href="/FAQ.php"> faq </ a> |
<a href="/support.php"> obter ajuda </ a> |
<a href="/mailing-lists.php"> listas de discussão </ a> |
<a href = "/ licença "> licenças </ a> |
<a href = " http://wiki.php.net/ "> wiki </ a> |
<a href = " http://bugs.php.net/ "> relatórios erros </ a> |
<a href="/sites.php"> php.net sites </ a> |
<a href="/links.php"> links </ a> |
<a href = "/ conferências / "> conferências </ a> |
<a href="/my.php"> minha php.net </ a>
Itens
href = downloads.php / - legenda = downloads
href = docs.php / - legenda = documentação
href = / faq.php - legenda = faq
href = / support.php - legenda = obter ajuda
href = / mailing-lists.php - legenda = mailing lists
href = licença / - legenda = licenças
href = http://wiki.php.net/ - legenda = wiki
href = http://bugs.php.net/ - legenda = reportar bugs
href = / sites . php - legenda = php.net locais
href = / links.php - legenda = links
href = / conferências / - legenda = conferências
href = / my.php - legenda = meu php.net
Creditos: Informatica br
A Extração de Dados desen Semper observar o autor do site e dependendo, Recomendo pedir autorização Prévia pingos de EUA o Processo normalmente. Principalmente Que TODO Acesso à Internet e sites de São rastreáveis e hum Acesso Constante certamente suspeitas poderá Gerar.
Código não abaixo, Faço uma Busca da Página do php.net e extraio ALGUMAS Informações Como o Título e como fazer OPÇÕES Menu.
Nao tenho Como explicar OBJETIVO Como Que voce fara uma Leitura dos Dados. O PHP temperatura o Suporte uma varias OPÇÕES Como o file_get_contents, curl OU fopen fsocket ou. Não dei exemplo a abaixo Preferência AO stream_context_create e stream_get_contents
DESDE Que tiva O Primeiro Contato com uma los Programação 1981, tenho uma USADO Máxima Que Manuais Encontrei Nós do Unix Anos atrás Onde Dizia "Use a Força, Leia a fonte", Use uma Força, leia o Fonte. Penso Que hum parágrafo Programador, hum Código Diz Muito Mais Que Páginas e manual, entao, estou publicando o resumo de Como Fazer uma Coisa.
<Php?
error_reporting (E_ALL & ~ E_NOTICE);
$ sourceURL = 'http://php.net';
$ opts = array ('http' => array ('método' => 'GET'
, 'follow_location' => '1 '
, 'max_redirects' => '10 '
, 'ignore_errors' => '1 ')
);
$ context = stream_context_create ($ opts);
$ stream = fopen ($ sourceURL, 'r', false, o contexto $) ;
$ content = stream_get_contents ($ stream);
echo '<pre>';
/ / echo htmlentities ($ content);
echo '<hr /> Pega o conteudo do <title>';
preg_match_all ('% <title> ( ? P <titulo> título [^<]+)>% ', $ content, $ matches, PREG_OFFSET_CAPTURE);
foreach ($ matches [0] as $ chave => $ value) {
echo '<br /> < b> Titulo </ b> = ', $ matches [' titulo '] [$ key] [0];
}
echo '<hr /> Todos: <a href =';
preg_match_all ('% (? P <caption> [^<]+) a>% ', $ content, $ matches, PREG_OFFSET_CAPTURE?);
foreach ($ matches [0] como $ valor => $ key) {
echo '<br /> href </ b> =', $ matches ['href'] [$ key] [0];
echo '- <b> legenda </ b > = ', $ matches [' legenda '] [$ key] [0];
}
preg_match_all (?% <div id="headmenu"> (P <menu> div .*?)</%> s ', partidas $ content, $, PREG_OFFSET_CAPTURE);
'<hr /> Somente o MENU' echo;
echo '<br /> Menu </ b> =', htmlentities ($ menu = $ matches [menu] [0] [0]);
preg_match_all ('% <a href = "(P
'<hr /> Itens' echo;
foreach ($ matches [0] as $ chave => $ value) {
echo '<br /> href </ b> =', $ matches ['href'] [$ key] [0];
echo '- <b> legenda </ b> =', $ partidas ['legenda'] [$ key] [0];
}
fclose ($ stream);
Resultado da execução do Programa:
Pega o conteudo do <title>
Titulo = PHP: Hypertext Preprocessor
Todos: <a href =
href = downloads.php / - legenda = downloads
href = docs.php / - legenda = documentação
href = / faq.php - legenda = faq
href = support.php / - legenda = obter ajuda
href = / discussão lists.php - legenda listas de discussão =
href = licença / - legenda = licenças
href = http://wiki.php.net/ - legenda = wiki
href = http://bugs.php.net/ - legenda = relatórios erros
href = / sites.php - legenda = php.net locais
href = / links.php - legenda = links
href = / conferências / - legenda = conferências
href = / my.php - legenda = meu php.net
href = tut / . php - legenda = tutorial introdutório
href = / docs.php - legenda = manual
href = links.php / - legenda = seção de links
href = usage.php / - legenda = Netcraft Pesquisa
href = thanks.php / - legenda = Obrigado
Redes
href = http://www.servercentral.net/ - legenda = Servidor Central
href = http://www.hostedsolutions.com/ - legenda = Hosted Solutions
href = http://www.spry.com/ - legenda = Spry VPS Hosting
href = http://ez.no/ - legenda = eZ Systems
href = http://www.hit.no/ - legenda = HiT
href = http://www.osuosl.org - legenda = OSU Aberto Fonte Lab
href = http://www.yahoo.com/ - legenda = Yahoo!
Webhosting
href = http://www.redpill-linpro.com - legenda = Redpill
- legenda = Atom feed
href = http://qa.php.net/rc.php - legenda = Os candidatos Lançamento
href = / submeter-event.php - legenda = [add]
href = http://www.php.net / conferências / index.php # id2011-08-11-1 - legenda = ConFoo 2012
href = http://www.php.net/conferences/index.php # id2011-05-30-1 - legenda = PHP North West , 2011
href = http://qa.php.net/ - legenda = alpha release
href = / releases/NEWS_5_4_0_ alpha1.txt - legenda = NEWS
href = mailto: php-qa@lists.php.net - legenda de discussão = QA lista
href = https://bugs.php.net/ - legenda = bug PHP rastreador
href = http://windows.php.net/qa/ - legenda =
site do Windows QA
href = https://wiki.php.net / rfc / releaseprocess / - legenda = releaseprocess RFC
href = / download docs.php-
- legenda = ChangeLog
href = downloads.php / - legenda = downloads
- legenda = este script
href = / archive / index.php - caption = Arquivo de Notícias
href = / feed.atom - legenda = Atom
href ?. = / source.php url = index / php - legenda = fonte mostram
href = / créditos . php - legenda = créditos
href = / stats / - legenda = stats
href = / sitemap.php - legenda = sitemap
href = / contact.php - legenda = contato
href = / contact.php # anúncios - legenda = publicidade
href = / mirrors.php - legenda = sites espelho
href = / copyright.php - legenda = Copyright © 2001-2011 O Grupo PHP
href = / mirror.php - caption = Este espelho
href = http://developer.yahoo.com/ - legenda = Yahoo! Inc.
Somente MENU o
menu =
<a href="/docs.php"> documentação </ a> |
<a href="/FAQ.php"> faq </ a> |
<a href="/support.php"> obter ajuda </ a> |
<a href="/mailing-lists.php"> listas de discussão </ a> |
<a href = "/ licença "> licenças </ a> |
<a href = " http://wiki.php.net/ "> wiki </ a> |
<a href = " http://bugs.php.net/ "> relatórios erros </ a> |
<a href="/sites.php"> php.net sites </ a> |
<a href="/links.php"> links </ a> |
<a href = "/ conferências / "> conferências </ a> |
<a href="/my.php"> minha php.net </ a>
Itens
href = downloads.php / - legenda = downloads
href = docs.php / - legenda = documentação
href = / faq.php - legenda = faq
href = / support.php - legenda = obter ajuda
href = / mailing-lists.php - legenda = mailing lists
href = licença / - legenda = licenças
href = http://wiki.php.net/ - legenda = wiki
href = http://bugs.php.net/ - legenda = reportar bugs
href = / sites . php - legenda = php.net locais
href = / links.php - legenda = links
href = / conferências / - legenda = conferências
href = / my.php - legenda = meu php.net
Creditos: Informatica br