Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ASP search engine inquiry- is it possible? How?

0 views
Skip to first unread message

Drewlin

unread,
Oct 31, 2002, 11:16:16 PM10/31/02
to
Hello, any help is much appreciated!

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!

TJS

unread,
Nov 1, 2002, 3:29:24 AM11/1/02
to
look into xmlhttp


Drewlin wrote in message
<9e644969.02103...@posting.google.com>...

Evertjan.

unread,
Nov 1, 2002, 4:32:00 AM11/1/02
to
Drewlin wrote on 01 Nov 2002 in microsoft.public.inetserver.asp.general:
> 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?


<%@ 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)

Lin Ma

unread,
Nov 1, 2002, 11:51:40 AM11/1/02
to
check this link may be help.

http://javascript.internet.com/miscellaneous/avenue-metasearch.html

Lin

"Drewlin" <ane...@hotmail.com> wrote in message
news:9e644969.02103...@posting.google.com...

Drewlin

unread,
Nov 2, 2002, 12:49:25 AM11/2/02
to
Thank you Evertjan!

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?

Evertjan.

unread,
Nov 2, 2002, 6:18:39 AM11/2/02
to
The answers below are only general idea's they have to be expanded into
real code and debugged.

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

unread,
Nov 3, 2002, 10:46:56 PM11/3/02
to
Thank you so much! Your help is greatly appreciated!

Drewlin

0 new messages