caxuda Posted June 28, 2015 at 12:17 AM Report #585488 Posted June 28, 2015 at 12:17 AM Boa noite, Gostaria de saber como posso criar um script php (ou noutra linguagem) que aceda a um site, por exemplo, o wikipedia, faça uma pesquisa no mesmo e retorne o HTML fornecido pela página. Não me interessam API do wikipedia que possam existir. Quero mesmo saber desenvolver uma coisa do género. Cumprimentos
bioshock Posted June 28, 2015 at 09:25 AM Report #585491 Posted June 28, 2015 at 09:25 AM $search = 'Portugal'; $html = file_get_contents('https://pt.wikipedia.org/wiki/' . $search); 1 Report
necas Posted June 28, 2015 at 01:39 PM Report #585494 Posted June 28, 2015 at 01:39 PM https://en.wikipedia.org/wiki/Web_scraping
caxuda Posted June 28, 2015 at 01:39 PM Author Report #585495 Posted June 28, 2015 at 01:39 PM Expliquei-me mal. Queria fazer uma pesquisa através formulário de pesquisa presente no site.
KTachyon Posted June 28, 2015 at 03:48 PM Report #585498 Posted June 28, 2015 at 03:48 PM A resposta está no link da form. Mas o resultado que vais obter é um redirect para uma página específica (ou de desambiguação, ou de não encontrado). No fundo, aquilo que queres é utilizar a API, que é o que a Wikipedia utiliza para o search-redirect. “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare
caxuda Posted June 28, 2015 at 03:54 PM Author Report #585499 Posted June 28, 2015 at 03:54 PM Eu sei que a API me resolvia o problema neste exemplo que dei. Estou a perguntar por outra solução porque a maioria dos sites não tem API.
KTachyon Posted June 28, 2015 at 03:59 PM Report #585501 Posted June 28, 2015 at 03:59 PM Mesmo que tivessem é provável que as APIs fossem diferentes, tal como os formulários de pesquisa têm parâmetros diferentes. Logo a solução que implementas para um site não será necessariamente semelhante à solução que implementas para outro site. “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now