?
Solved

Delphi webbrowser autoclick

Posted on 2011-04-24
4
Medium Priority
?
926 Views
Last Modified: 2012-05-11
Hello experts.
Please help.
I have a form and a webbrowser.
How can i make a procedure that clicks to a link inside a script?
example : the output html of this link is :
<script charset="windows-1251" type="text/javascript" src="http://www.directadvert.ru/show.cgi?adp=16548&div=DIV_DA_16548"></script>
but the link is randomized and looks like this :
http://www.directadvert.ru/click.cgi?h=51e98389d907489549e5dea30107234e&a=16548:15098517:142511&p=2&url=http%3A%2F%2Fwww.directadvert.ru%2Fnews%2F%3Fid%3D16540%26nnn_id=15098517

Can anyone help me?
0
Comment
Question by:helyonprime96
  • 2
  • 2
4 Comments
 
LVL 24

Accepted Solution

by:
jimyX earned 2000 total points
ID: 35456321
You can loop through all the scripts and click on the links:
procedure TForm1.Button1Click(Sender: TObject);
var
  i:integer;
  OScrpts:OleVariant;
begin
  OScrpts := WebBrowser1.OleObject.Document.all.tags('Script');
  if OScrpts.Length > 0 then
    begin
      for i := 0 to OScrpts.Length-1 do
        begin
          if Pos('http://www.directadvert.ru', OScrpts.Item(i).Src) > 0 then
            begin
              OScrpts.Item(i).click;
              Memo1.Lines.Add(OScrpts.item(i).Src); // Just to view the clicked links
            end;
        end;
    end;
end;

Open in new window

0
 

Author Comment

by:helyonprime96
ID: 35460101
hey, thanks for your code, but it doesnt clicks.
on memo1 are showing correct links, but code doesnt click link.
0
 
LVL 24

Assisted Solution

by:jimyX
jimyX earned 2000 total points
ID: 35460152
Hmmm, because it's not a link tag. You can just open it in the WebBrowser instead of clicking. So line 13 becomes:

WebBrowser1.Navigate(OScrpts.Item(i).Src);

But you will be able to open only one link.
0
 

Author Closing Comment

by:helyonprime96
ID: 35810956
thanks
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Simple Linear Regression
Loops Section Overview

840 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