Solved

Retrieve the page from google for a search string

Posted on 2007-11-19
8
135 Views
Last Modified: 2010-04-05
Hi.

I'd like to insert a specific search word and then submit this query to google.
Then retrieve the number of the result for a specific web page.

For example :
Word : "Experts Delphi source code"
Result : The page "Experts-exchange.com" is in   -> Page 3 , result #37

Thanks in advance.
0
Comment
Question by:CodedK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 19

Expert Comment

by:MerijnB
ID: 20313308
0
 
LVL 16

Author Comment

by:CodedK
ID: 20313690
Hi MerijnB.
How can this help ?
0
 
LVL 28

Accepted Solution

by:
2266180 earned 500 total points
ID: 20314100
function Google_Search( keywords: TStringList ): TStringList;
begin
  Result := nil;
end;

lol :)

even though the problem is simple, it's not that simple.

if the above function would have had some code, then you could have modified that code pretty strait forward.

without that, you can do soemthing like this:

i:=0;
p:=0;// this will be the page
repeat
  html:=get_html('http://www.google.com/search?q='+url_encode(search query)+'&hl=en&start='+inttostr(i*10)+'&sa=N');
  inc(i);
  if pos(the_site, html)>0 then
    p:=i;
until p>0;

and you have the page in p.
ugly, but it will work :)

get_html is your prffered way of getting the html. I preffer indy: idhttp1.get(url)
url_encode is again your preffered way of encoding a string for url, mine is again indy: TIdUri.urlencode(text); (yes, it's a class function)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:MerijnB
ID: 20314449
oops, there used to be something usefull in there...
0
 
LVL 16

Author Comment

by:CodedK
ID: 20322755
Bad ciuly ... Lol
Thanks :)
0
 
LVL 28

Expert Comment

by:2266180
ID: 20322975
>> Bad ciuly ... Lol
why? the solution, not clean or beatifull, I know, but certainly speed optimal, short and easy to understand.
consider that almost any other solution (even that of merijnb if there was code tehre) involved parsing, which would mean more oeprations. you can further optimize for string speed tehre but since it's a network connection involved it doesn't really matter since generally it won't be noticeable.
tehre was one time the option of using google api but as I heard some time ago they are not giving the needed google api key anymore whithout which you cannot access some or all of the google api.
not to mention that this way it works on any search engine :P
0
 
LVL 16

Author Comment

by:CodedK
ID: 20323352
No ciuly your solution is good, clean and.. pliable. (I think this is a good word)
I said it coz of this >> mine is again indy: TIdUri.urlencode(text); (yes, it's a class function)
And i dont mean bad...bad ... but bad like SouthPark ("Rainforest Shmainforest") :P
Thanks :)
0
 
LVL 28

Expert Comment

by:2266180
ID: 20323944
ha. now I see hom I'm talking to :D
sorry, but I almost never look at the question asker when answering :)
I'm usually pressed by time so all I do is look at the question titile in the filter result, if it looks fast-answerable, I open it and read the question fast and answer even faster.
I never got around to making that utility I talked about since I'm too busy so this makes my life harder here. maybe next year :D

PS: I don't watch SouthPark :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question