Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Retrieve the page from google for a search string

Posted on 2007-11-19
8
Medium Priority
?
137 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 2000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

604 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