如何自动点击网页链接?

时间:2015-06-26 20:43:09

标签: winforms visual-studio-2010 c#-4.0

以下代码是我需要点击链接的地方。

我已经想出如何浏览网站并以编程方式登录网站。但是,现在我需要能够自动导航网站,但我无法管理它。

包含“时钟输入”的行是我需要点击的链接...

我是编码的新手。这是我的第一个项目。

对不起。我没有意识到我的早期复制/粘贴已被缩短。我已经更正了包含链接的行。

再次,谢谢。

<div id="dockedContent" class="dockedContent">

    <div id="RecentlyVisitedWidget" class="recentlyVisitedWidget">

    <h2 id="ctl00_12_12_RecentlyVisitedLabel"></h2>
    <ul class="recentlyVisitedLinks">
        <li>
            <span id="ctl00_12_12_Repeater1_ctl00_link">
                <a href="#" onclick="recentlyVisitedSelect('pages/VIEW/UTMEntry.aspx?USParams=PK=ESS!MenuID=2147!PageRerId=2147!ParentRerId=72','72','2147','2147', false, false, 'Time Clock Entry', true)" title="Time Clock Entry">Time Clock Entry</a>    
                </span>
            </li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>

</div>

1 个答案:

答案 0 :(得分:0)

您可以找到以下链接:

import javax.swing.*;
import java.util.Scanner;

public class Program3
{
public static void main(String[] args)
{
    final int NUMBER_OF_ITEMS = 5;
    int[]productNum = {1,2,3,4,5};   //array of product numbers
    double[]price = {2.98, 4.50, 9.98, 4.49, 6.87};   //array of
            price
    double quantity, product, total;
    Scanner input = new Scanner(System.in);
    System.out.print("Enter Product Number (1-5) or -1 to Quit:");
    productNum = input.nextInt();
            System.out.print("Enter Quantity:");
    quantity = input.nextDouble();
    total = product*quantity;
    System.out.print(total);
}
}

这基本上是说“获取文档中的所有HtmlElement link = (from HtmlElement elem in webBrowser.Document.GetElementsByTagName("a") where elem.GetAttribute("title") == "Time Clock Entry" select elem).ElementAt(0); 标记(以及所有链接),然后进行过滤,以便我只获得标题为a的{​​{1}}个标记。你已经做到了,给我第一个这样的元素。“

然后以编程方式点击它:

a