Ir para conteúdo
Fórum Script Brasil
  • 0

(Resolvido) Te como adaptar esse busca?


marvi

Pergunta

Olá pessoal, estou com esse código de busca aqui, é um javascript que tem o campo onde permite escolher se você quer buscar pelo google, yahoo e etc, mas deixei assim, pode copiar e colcar no seu html para ver e fazer o teste:

<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Yahoo DMOZ Snap Alta Vista&nbsp; Direct Hit&nbsp; Lycos&nbsp; Excite 
Webcrawler Go</title>
<script LANGUAGE="Javascript">Yahoo = "http://search.yahoo.com/bin/search?p=";Alta = "http://www.altavista.digital.com/cgi-bin/query?pg=q&what=web&q=";Direct = "http://www.directhit.com/fcgi-bin/DirectHitWeb.fcg?alias=websrch&qry=";Lycos = "http://www.lycos.com/cgi-bin/pursuit?query=";Crawler = "http://www.webcrawler.com/cgi-bin/WebQuery?searchText=";GoCom = "http://www.go.com/Titles?col=WW&svx=home_searchbox&sv=IS&lk=noframes&qt=";DejaNews = "http://www.deja.com/products/search/search.xp?PVW=&QRY=";Google = "http://www.google.com.br/search?q=";Go2Net = "http://search.metacrawler.com/crawler?method=0&searchType=web&format=portal&cat=web&redirect=&target=&power=1&opendir_p1=&p_region=&query=&general=";SearchCom = "http://www.search.com/search?channel=1&tag=st.se.fd..sch&submit=Search&q=";Mamma = "http://www.mamma.com/Mamma?p1=1&timeout=4&qtype=0&query=";DogPile = "http://search.dogpile.com/texis/search?geo=no&fs=web&av=custom&engines=goto&engines=looksmart&engines=thunderstone&engines=findwhat &engines=sprinks &engines=directhit &engines=google &engines=infoseek &engines=lycos &engines=kanoodle &engines=opendir &engines=realnames &engines=altavista&engines=yahoo&q="; Excite = "http://www.excite.com/search.gw?searchType=Concept&search="; DMOZ = "http://search.dmoz.org/cgi-bin/search?search=";Snap = "http://www.nbci.com/search/directory/results/1,61,-0,00.html?tag=st.sn.fd.srch.bar&keyword="; Galaxy = "http://www.einet.net/cgi-bin/wais-text-multi?keywords=";var got=0; var url = "";var plus="";var mag="";function search4(item){stringPlus();resultsWindow=window.open();resultswindow.document.open();resultswindow.document.write("<head><title>Close this window "+ "to return to Search Page</title></head>"+ "<FRAMESET ROWS=50%,50%><FRAMESET COLS=50%,50%>"+ "<FRAME NAME='frame0' SRC='" + computeFrameSrc(0) + "'>"+ "<FRAME NAME='frame1' SRC='" + computeFrameSrc(1) + "'>"+ "</FRAMESET><FRAMESET COLS=50%,50%><FRAME NAME='frame2' "+ "SRC='" + computeFrameSrc(2) + "'><FRAME NAME='frame3' "+ "SRC='" + computeFrameSrc(3) + "'></FRAMESET></FRAMESET>");resultswindow.document.close();got = 0;}function search2(item){stringPlus();resultsWindow=window.open();resultswindow.document.open();resultswindow.document.write("<head><title>Close this window "+ "to return to Total search</title></head><FRAMESET ROWS=50%,50%>"+ "<FRAME NAME='frame0' SRC='" + computeFrameSrc(0) + "'><FRAME "+ "NAME='frame1' SRC='" + computeFrameSrc(1) + "'></FRAMESET>");resultswindow.document.close();got = 0;}function stringPlus() {for (var j=0; j < window.document.choose4.text.value.length; j++) {if (window.document.choose4.text.value.charAt(j) == " ")mag += "+";else mag += window.document.choose4.text.value.charAt(j);}}function numChecked(item) {plus = escape(item.text.value);var h=0;num=0;for (var l=0; l < item.check1.length; l++) {if (item.check1[l].checked) {h++;if (h++ <= 4){if (l == "0"){num = 1;}else if (l == "1") num = 2;else if (l == "2") num = 3;else if (l == "3") num = 4;else if (l == "4") num = 5;else if (l == "5") num = 6;else if (l == "6") num = 7;else if (l == "7") num = 8;else if (l == "8") num = 9;else if (l == "9") num = 10;else if (l == "10") num = 11;else if (l == "11") num = 12;else if (l == "12") num = 13;else if (l == "13") num = 14;else if (l == "14") num = 15;      }   }}if (h == 2)Results(num-1);else if (h == 4)search2(item);elsesearch4(item);}function computeFrameSrc(num) {var k=-1;for (var j=got; j < document.choose4.check1.length; j++) {if (document.choose4.check1[j].checked){k++;if (k++ <= num){if (j == "0"){url = Yahoo + plus;got = 1;}else if (j == "1"){url = DMOZ + plus;got = 2;}else if (j == "2"){url = Snap + plus;got = 3;}else if (j == "3"){url = Alta + plus + "&mode=and";got = 4;}else if (j == "4"){url = Direct + plus;got = 5;}else if (j == "5"){url = Lycos + plus + "&backlink=217&maxhits=25";got = 6;}else if (j == "6"){url = Excite + plus + "&category=default&mode=relevance&showqbe=1&display=html3,hb";got = 7;}else if (j == "7"){url = Crawler + plus + "&maxHits=25";got = 8;}else if (j == "8"){url = GoCom + plus;got = 9;}else if (j == "9"){url = DejaNews + plus + "&defaultOp=AND&svcclass=dncurrent&maxhits=25";got = 10;}else if (j == "10"){url = Google + plus;got = 11;}else if (j == "11"){url = Go2Net + plus;got = 12;}else if (j == "12"){url = SearchCom + plus;got = 13;}else if (j == "13"){url = Mamma + plus;got = 14;}else if (j == "14"){url = DogPile + plus;got = 15;}return url;      }   }}url = "java script:void(0)";return url;}function Results(place){stringPlus();resultsWin = window.open("","results");if (place == "0")url = Yahoo + plus;else if (place == "1")url = DMOZ + plus;else if (place == "2")url = Snap + plus;else if (place == "3")url = Alta + plus + "&mode=and";else if (place == "4")url = Direct + plus + "&mode=and";else if (place == "5")url = Lycos + plus + "&backlink=217&maxhits=25";else if (place == "6")url = Excite + plus + "&category=default&mode=relevance&showqbe=1&display=html3,hb";else if (place == "7")url = Crawler + plus + "&maxHits=25";else if (place == "8")url = GoCom + plus;else if (place == "9")url = DejaNews + plus + "&defaultOp=AND&svcclass=dncurrent&maxhits=25";else if (place == "10")url = Google + plus + "&hits=25&disp=Text+Only";else if (place == "11")url = Go2Net + plus;else if (place == "12")url = SearchCom + plus;else if (place == "13")url = Mamma + plus;else if (place == "14")url = DogPile + plus;resultsWin.location = url;}// End  --></script>
</head>

<body>
<form name="choose4" action="java script:numChecked(document.choose4) //">
<input type="hidden" name="check1" value="Yahoo"onclick="choose4.check1.value='Yahoo'">
<input type="hidden" name="check1" value="DMOZ"onclick="choose4.check1.value='DMOZ'">
<input type="hidden" name="check1" value="Snap"onclick="choose4.check1.value='Snap'">

<input type="hidden" name="check1" value="Alta"onclick="choose4.check1.value='Alta'">
<input type="hidden" name="check1" value="Direct"onclick="choose4.check1.value='Direct'">
<input type="hidden" name="check1" value="Lycos"onclick="choose4.check1.value='Lycos'">
<input type="hidden" name="check1" value="Excite"onclick="choose4.check1.value='Excite'">
<input type="hidden" name="check1" value="Crawler"onclick="choose4.check1.value='Crawler'">
<input type="hidden" name="check1" value="Go.com"onclick="choose4.check1.value='Go.com'">
<input type="hidden" name="check1" value="DejaNews"onclick="choose4.check1.value='DejaNews'">
<input type="checkbox" name="check1" value="Google"onclick="choose4.check1.value='Google'">Google

<input type="hidden" name="check1" value="Go2Net"onclick="choose4.check1.value='Go2Net'">
<input type="hidden" name="check1" value="SearchCom"onclick="choose4.check1.value='SearchCom'">
<input type="hidden" name="check1" value="Mamma"onclick="choose4.check1.value='Mamma'">
<input type="hidden" name="check1" value="DogPile"onclick="choose4.check1.value='DogPile'">

<input type="text" name="text" size=30><input type="submit" name="send" value="Search"></form>
</form>
</body>

</html>

Ok? Mas, a questão é:

O busca que é mostrado acima pesquisa no google se a pessoal selecionar a opção o google, agora se a pessoa selecionar localmente como vou fazer o busca pegar o SQL e consultar meu próprio banco?

Minha sql é:

SELECT * FROM banco WHERE titulo LIKE '%"& varbusca &"%' OR texto LIKE '%"& varbusca &"%' ORDER BY alteracao DESC

Como iria fazer esse script deixar de consultar o google e consultar meu banco?

Tem como? Senão, tem outro busca que conheça que tenha essa capacidade? Pois, venho a tempo tentando e até onde conseguir foi o que mostrei acima.

Desde já, agradeço muito!

Editado por bareta
Link para o comentário
Compartilhar em outros sites

5 respostass a esta questão

Posts Recomendados

  • 0

não parei para analisar o js... mais é so adicionar a opção para local e o endereço...

<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Yahoo DMOZ Snap Alta Vista&nbsp; Direct Hit&nbsp; Lycos&nbsp; Excite 
Webcrawler Go</title>
<script LANGUAGE="Javascript">
Yahoo = "http://search.yahoo.com/bin/search?p=";
Alta = "http://www.altavista.digital.com/cgi-bin/query?pg=q&what=web&q=";
Direct = "http://www.directhit.com/fcgi-bin/DirectHitWeb.fcg?alias=websrch&qry=";
Lycos = "http://www.lycos.com/cgi-bin/pursuit?query=";
Crawler = "http://www.webcrawler.com/cgi-bin/WebQuery?searchText=";
GoCom = "http://www.go.com/Titles?col=WW&svx=home_searchbox&sv=IS&lk=noframes&qt=";
DejaNews = "http://www.deja.com/products/search/search.xp?PVW=&QRY=";
Google = "http://www.google.com.br/search?q=";
Go2Net = "http://search.metacrawler.com/crawler?method=0&searchType=web&format=portal&cat=web&redirect=&target=&power=1&opendir_p1=&p_region=&query=&general=";
SearchCom = "http://www.search.com/search?channel=1&tag=st.se.fd..sch&submit=Search&q=";
Mamma = "http://www.mamma.com/Mamma?p1=1&timeout=4&qtype=0&query=";
DogPile = "http://search.dogpile.com/texis/search?geo=no&fs=web&av=custom &engines=goto&engines=looksmart &engines=thunderstone &engines=findwhat&engines=sprinks &engines=directhit&engines=google &engines=infoseek&engines=lycos &engines=kanoodle&engines=opendir &engines=realnames&engines=altavista&engines=yahoo&q=";
Excite = "http://www.excite.com/search.gw?searchType=Concept&search=";
DMOZ = "http://search.dmoz.org/cgi-bin/search?search=";
Snap = "http://www.nbci.com/search/directory/results/1,61,-0,00.html?tag=st.sn.fd.srch.bar&keyword=";
Galaxy = "http://www.einet.net/cgi-bin/wais-text-multi?keywords=";
var got=0;
var url = "";
var plus="";
var mag="";
function search4(item){
stringPlus();
resultsWindow=window.open();
resultswindow.document.open();
resultswindow.document.write("<head><title>Close this window "+ "to return to Search Page</title></head>"+ "<FRAMESET ROWS=50%,50%><FRAMESET COLS=50%,50%>"+ "<FRAME NAME='frame0' SRC='" + computeFrameSrc(0) + "'>"+ "<FRAME NAME='frame1' SRC='" + computeFrameSrc(1) + "'>"+ "</FRAMESET><FRAMESET COLS=50%,50%><FRAME NAME='frame2' "+ "SRC='" + computeFrameSrc(2) + "'><FRAME NAME='frame3' "+ "SRC='" + computeFrameSrc(3) + "'></FRAMESET></FRAMESET>");
resultswindow.document.close();
got = 0;
}
function search2(item){
stringPlus();
resultsWindow=window.open();
resultswindow.document.open();
resultswindow.document.write("<head><title>Close this window "+ "to return to Total search</title></head><FRAMESET ROWS=50%,50%>"+ "<FRAME NAME='frame0' SRC='" + computeFrameSrc(0) + "'><FRAME "+ "NAME='frame1' SRC='" + computeFrameSrc(1) + "'></FRAMESET>");
resultswindow.document.close();
got = 0;
}function stringPlus() {
for (var j=0; j < window.document.choose4.text.value.length; j++) {
if (window.document.choose4.text.value.charAt(j) == " "){
mag += "+";
}else{
 mag += window.document.choose4.text.value.charAt(j);
}
}
}
function numChecked(item) {
plus = escape(item.text.value);
var h=0;
num=0;
for (var l=0; l < item.check1.length; l++) {
if (item.check1[l].checked) {
h++;
if (h++ <= 4){
if (l == "0"){
num = 1;
}else if (l == "1"){
num = 2;
}else if (l == "2"){
num = 3;
}else if (l == "3"){
num = 4;
}else if (l == "4"){
num = 5;
}else if (l == "5"){
num = 6;
}else if (l == "6"){
num = 7;
}else if (l == "7"){
num = 8;
}else if (l == "8"){
num = 9;
}else if (l == "9"){
num = 10;
}else if (l == "10"){
num = 11;
}else if (l == "11"){
num = 12;
}else if (l == "12"){
num = 13;
}else if (l == "13"){
num = 14;
}else if (l == "14"){
num = 15;
}
}
}
if (h == 2){
Results(num-1);
}else if (h == 4){
search2(item);
}else{
search4(item);
}
function computeFrameSrc(num) {
var k=-1;
for (var j=got; j < document.choose4.check1.length; j++) {
if (document.choose4.check1[j].checked){
k++;
if (k++ <= num){
if (j == "0"){
url = Yahoo + plus;
got = 1;
}else if (j == "1"){
url = DMOZ + plus;
got = 2;
}else if (j == "2"){
url = Snap + plus;
got = 3;
}else if (j == "3"){
url = Alta + plus + "&mode=and";
got = 4;
}else if (j == "4"){
url = Direct + plus;
got = 5;
}else if (j == "5"){
url = Lycos + plus + "&backlink=217&maxhits=25";
got = 6;
}else if (j == "6"){
url = Excite + plus + "&category=default&mode=relevance&showqbe=1&display=html3,hb";
got = 7;
}else if (j == "7"){
url = Crawler + plus + "&maxHits=25";
got = 8;
}else if (j == "8"){
url = GoCom + plus;
got = 9;
}else if (j == "9"){
url = DejaNews + plus + "&defaultOp=AND&svcclass=dncurrent&maxhits=25";
got = 10;
}else if (j == "10"){
url = Google + plus;
got = 11;
}else if (j == "11"){
url = Go2Net + plus;
got = 12;
}else if (j == "12"){
url = SearchCom + plus;
got = 13;
}else if (j == "13"){
url = Mamma + plus;
got = 14;
}else if (j == "14"){
url = DogPile + plus;
got = 15;
}else{
return url;
}
}
}
url = "java script:void(0)";
return url;
}
function Results(place){
stringPlus();
resultsWin = window.open("","results");
if (place == "0"){
url = Yahoo + plus;
}else if (place == "1"){
url = DMOZ + plus;
}else if (place == "2"){
url = Snap + plus;
}else if (place == "3"){
url = Alta + plus + "&mode=and";
}else if (place == "4"){
url = Direct + plus + "&mode=and";
}else if (place == "5"){
url = Lycos + plus + "&backlink=217&maxhits=25";
}else if (place == "6"){
url = Excite + plus + "&category=default&mode=relevance&showqbe=1&display=html3,hb";
}else if (place == "7"){
url = Crawler + plus + "&maxHits=25";
}else if (place == "8"){
url = GoCom + plus;
}else if (place == "9"){
url = DejaNews + plus + "&defaultOp=AND&svcclass=dncurrent&maxhits=25";
}else if (place == "10"){
url = Google + plus + "&hits=25&disp=Text+Only";
}else if (place == "11"){
url = Go2Net + plus;
}else if (place == "12"){
url = SearchCom + plus;
}else if (place == "13"){
url = Mamma + plus;
}else if (place == "14"){
url = DogPile + plus;
resultsWin.location = url;
}
// End  -->
</script>

Link para o comentário
Compartilhar em outros sites

  • 0

Sim, fiz um teste, mudei o do Yahoo por exemplo e chamou a página certa:

Yahoo = "http://www.site.com.br/busca.asp?busca=

E funcionou!

Mas, qual seria a solução de não abrir em outra janela? Pois ele usa um windows.open na linha:

window.open("","results")

outra linha:

resultsWindow=window.open();resultswindow.document.open();resultswindow.document.write("<head><title>Close ....

Como fazer que abra na mesma janela?

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,1k
×
×
  • Criar Novo...