Solved

Retrieve the page from google for a search string

Posted on 2007-11-19
8
134 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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
Help on project with Soap 10 69
Reconfigure Delphi Install? 2 76
MS Access from Delphi 31 100
Delphi Firmonkey, Android:  blocking dialogs not implemented on this platform 5 92
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

732 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