Is there anyway for me to query a search engine on another website
from my website? I would like to have a form on my site with one
input box and a search button. Upon pressing the search button, how
can I use this input to query a search engine on another site and
place certain search results back on my site?
I am donating my time on this for a non-profit charity organization,
and we don't have much money to spend, so pricy out-of-box solutions
are out of the question for us. I am decent with ASP, and would like
to be able to code the ASP into this application myself. Thank you
for your help!
Drewlin wrote in message
<9e644969.02103...@posting.google.com>...
<%@ LANGUAGE=VBScript ENABLESESSIONSTATE=True %>
<% Response.Buffer=True %>
<%
Function GetHTML(strPage)
On Error Resume Next
Set objXMLHttp = Server.CreateObject ("Microsoft.XMLHTTP")
objXMLHttp.Open "GET", strPage ,False,"",""
objXMLHttp.Send
If Err.Number = 0 Then
If objXMLHttp.Status = 200 then
GetHTML = objXMLHttp.ResponseText
Else
GetHTML = "Incorrect URL"
End if
Else
GetHTML = Err.Description
End If
Set objXMLHttp = Nothing
End Function
%>
ha ============================================<br>
<%=GetHTML("http://www.google.com/search?as_q=apple&num=100&hl=nl&ie=UTF-
8&oe=UTF-
8&newwindow=1&btnG=Google+zoeken&as_epq=&as_oq=&as_eq=&lr=&as_ft=i&as_filet
ype=&as_qdr=all&as_occt=any&as_dt=i&as_sitesearch=")%>
<br>ha ============================================
--------------------------------------------------------------
Please repair the line overflow in this post
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
http://javascript.internet.com/miscellaneous/avenue-metasearch.html
Lin
"Drewlin" <ane...@hotmail.com> wrote in message
news:9e644969.02103...@posting.google.com...
That code works great, thank you. I was wondering if you or someone
else could help with a couple of more things:
1) When I use this code as you have it, it will display the search
results on my page, and the links work fine. However, if I use this
code to query another search engine that displays results as relative
references, none of the links work because it is trying to find the
files relative to my page. Is there a peice of code that I can insert
that will automatically "find and replace" all the relative URLs with
absolute URLs before the results are displayed on my page?
2) How can I pull only certain peices (one or two words) of the
results and edit the appearance of the results to fit into my own
theme or styles?
3) I can change the code manually to search for what I want by
changing the "apple" but how can I insert this search keyword from a
form?
Advice: first scrutinize the html-sourcecode returned by Google, etc. after
a NORMAL query from your own browser.
Drewlin wrote on 02 Nov 2002 in microsoft.public.inetserver.asp.general:
> 1) When I use this code as you have it, it will display the search
> results on my page, and the links work fine. However, if I use this
> code to query another search engine that displays results as relative
> references, none of the links work because it is trying to find the
> files relative to my page. Is there a peice of code that I can insert
> that will automatically "find and replace" all the relative URLs with
> absolute URLs before the results are displayed on my page?
<base href="http://www.altavista.com/">
or
<%
result=replace(result,"href=""/","href=""http://www.altavista.com/")
result=replace(result,"href='/","href='http://www.altavista.com/")
%>
> 2) How can I pull only certain peices (one or two words) of the
> results and edit the appearance of the results to fit into my own
> theme or styles?
<%
searchword = "pear"
result=GetHTML("http://www.google.com/search?as_q=" & searchword )
' For the GetHTML() see the earlier thread
' this is the bare minimum for Google, I think
p = instr(800,Lcase(result),"pear")
' 800 will hopefully carry you over the top of the page
' Lcase will make the search caseinsensitive
result = mid(result,p-50,300)
' this will write 50 chars before "pear" and a total of 300 chars
response.write result
%>
> 3) I can change the code manually to search for what I want by
> changing the "apple" but how can I insert this search keyword from a
> form?
>
<%
searchword = request.form("searching")
%>
<br>
<%=GetHTML("http://www.google.com/search?as_q=" & searchword)%>
<br> blah
Drewlin