首页 > 解决方案 > UiPath 自动在网页上按顺序点击列表

问题描述

这是我正在查看的网站。

在这个网站上有一个公司列表,我可以点击它们:

  1. 点击公司名称
  2. 点击“年度报告”按钮
  3. 点击“Annual Report & CG Report - 2018”链接

此列表中有 788 家公司,我希望对整个列表重复此过程。这可能吗?

目前我使用Data Scraping-> Attach Browser url-> Extract Structured Data。之后我被卡住了。

标签: uipathuipath-studio

解决方案


对我来说,这听起来很简单:

  1. 转到概览
  2. 通过数据抓取下载列表
  3. 对于该列表中的每个并浏览每个这些url
  4. url上做你说的事情,比如点击年度报告,然后点击年度报告和 CG 报告 - 2018

所以 UiPath 进程的通常结构是这样的:

在此处输入图像描述

这是适用于您的示例的 Main.xaml视觉概述

在此处输入图像描述

这是 Main.xaml代码

<Activity mc:Ignorable="sap sap2010" x:Class="Main" mva:VisualBasic.Settings="{x:Null}" sap:VirtualizedContainerService.HintSize="530,1075" sap2010:WorkflowViewState.IdRef="ActivityBuilder_1" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:ui="http://schemas.uipath.com/workflow/activities" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <TextExpression.NamespacesForImplementation>
    <scg:List x:TypeArguments="x:String" Capacity="22">
      <x:String>System.Activities</x:String>
      <x:String>System.Activities.Statements</x:String>
      <x:String>System.Activities.Expressions</x:String>
      <x:String>System.Activities.Validation</x:String>
      <x:String>System.Activities.XamlIntegration</x:String>
      <x:String>Microsoft.VisualBasic</x:String>
      <x:String>Microsoft.VisualBasic.Activities</x:String>
      <x:String>System</x:String>
      <x:String>System.Collections</x:String>
      <x:String>System.Collections.Generic</x:String>
      <x:String>System.Data</x:String>
      <x:String>System.Diagnostics</x:String>
      <x:String>System.Drawing</x:String>
      <x:String>System.IO</x:String>
      <x:String>System.Linq</x:String>
      <x:String>System.Net.Mail</x:String>
      <x:String>System.Xml</x:String>
      <x:String>System.Xml.Linq</x:String>
      <x:String>UiPath.Core</x:String>
      <x:String>UiPath.Core.Activities</x:String>
      <x:String>System.Windows.Markup</x:String>
      <x:String>UiPath.CV</x:String>
    </scg:List>
  </TextExpression.NamespacesForImplementation>
  <TextExpression.ReferencesForImplementation>
    <scg:List x:TypeArguments="AssemblyReference" Capacity="18">
      <AssemblyReference>System.Activities</AssemblyReference>
      <AssemblyReference>Microsoft.VisualBasic</AssemblyReference>
      <AssemblyReference>mscorlib</AssemblyReference>
      <AssemblyReference>System.Data</AssemblyReference>
      <AssemblyReference>System</AssemblyReference>
      <AssemblyReference>System.Drawing</AssemblyReference>
      <AssemblyReference>System.Core</AssemblyReference>
      <AssemblyReference>System.Xml</AssemblyReference>
      <AssemblyReference>System.Xml.Linq</AssemblyReference>
      <AssemblyReference>PresentationFramework</AssemblyReference>
      <AssemblyReference>WindowsBase</AssemblyReference>
      <AssemblyReference>PresentationCore</AssemblyReference>
      <AssemblyReference>System.Xaml</AssemblyReference>
      <AssemblyReference>UiPath.System.Activities</AssemblyReference>
      <AssemblyReference>UiPath.UiAutomation.Activities</AssemblyReference>
      <AssemblyReference>UiPath.CV</AssemblyReference>
      <AssemblyReference>System.ValueTuple</AssemblyReference>
      <AssemblyReference>System.Data.DataSetExtensions</AssemblyReference>
    </scg:List>
  </TextExpression.ReferencesForImplementation>
  <Sequence sap:VirtualizedContainerService.HintSize="510,975" sap2010:WorkflowViewState.IdRef="Sequence_3">
    <Sequence.Variables>
      <Variable x:TypeArguments="sd:DataTable" Default="[New System.Data.DataTable]" Name="ExtractDataTable" />
      <Variable x:TypeArguments="ui:Browser" Name="Browser" />
    </Sequence.Variables>
    <sap:WorkflowViewStateService.ViewState>
      <scg:Dictionary x:TypeArguments="x:String, x:Object">
        <x:Boolean x:Key="IsExpanded">True</x:Boolean>
      </scg:Dictionary>
    </sap:WorkflowViewStateService.ViewState>
    <ui:OpenBrowser CommunicationMethod="{x:Null}" Hidden="{x:Null}" NewSession="{x:Null}" Private="{x:Null}" BrowserType="Firefox" DisplayName="Open Browser" sap:VirtualizedContainerService.HintSize="468,351" sap2010:WorkflowViewState.IdRef="OpenBrowser_1" UiBrowser="[Browser]" Url="https://www.bursamalaysia.com/trade/trading_resources/listing_directory/main_market">
      <ui:OpenBrowser.Body>
        <ActivityAction x:TypeArguments="x:Object">
          <ActivityAction.Argument>
            <DelegateInArgument x:TypeArguments="x:Object" Name="ContextTarget" />
          </ActivityAction.Argument>
          <ui:BrowserScope Browser="{x:Null}" SearchScope="{x:Null}" TimeoutMS="{x:Null}" UiBrowser="{x:Null}" BrowserType="Firefox" DisplayName="Attach Browser" sap:VirtualizedContainerService.HintSize="434,252" sap2010:WorkflowViewState.IdRef="BrowserScope_2" InformativeScreenshot="49520eaf054f3a2d88e58aa9f0f1cdb7" Selector="&lt;html app='firefox.exe' title='Main Market' /&gt;">
            <ui:BrowserScope.Body>
              <ActivityAction x:TypeArguments="x:Object">
                <ActivityAction.Argument>
                  <DelegateInArgument x:TypeArguments="x:Object" Name="ContextTarget" />
                </ActivityAction.Argument>
                <ui:ExtractData DelayBetweenPagesMS="{x:Null}" ContinueOnError="True" DataTable="[ExtractDataTable]" DisplayName="Extract Structured Data" ExtractMetadata="&lt;extract&gt;&lt;column exact='1' name='Name' attr='text' name2='URL' attr2='href'&gt;&lt;webctrl tag='tr'/&gt;&lt;webctrl tag='td' class=' text-left position-relative'/&gt;&lt;webctrl tag='a' class='company-announcement-link' idx='1'/&gt;&lt;/column&gt;&lt;/extract&gt;" sap:VirtualizedContainerService.HintSize="334,106" sap2010:WorkflowViewState.IdRef="ExtractData_2" MaxNumberOfResults="100" NextLinkSelector="&lt;webctrl parentid='DataTables_Table_0_next' tag='A' /&gt;" SimulateClick="True">
                  <ui:ExtractData.Target>
                    <ui:Target ClippingRegion="{x:Null}" Element="{x:Null}" InformativeScreenshot="c9106f042e4e67a92a010ed284896366" Selector="&lt;webctrl parentid='DataTables_Table_0' tag='TBODY' /&gt;" WaitForReady="COMPLETE">
                      <ui:Target.TimeoutMS>
                        <InArgument x:TypeArguments="x:Int32" />
                      </ui:Target.TimeoutMS>
                    </ui:Target>
                  </ui:ExtractData.Target>
                </ui:ExtractData>
              </ActivityAction>
            </ui:BrowserScope.Body>
          </ui:BrowserScope>
        </ActivityAction>
      </ui:OpenBrowser.Body>
    </ui:OpenBrowser>
    <ui:ForEachRow CurrentIndex="{x:Null}" DataTable="[ExtractDataTable]" DisplayName="For Each Row" sap:VirtualizedContainerService.HintSize="468,492" sap2010:WorkflowViewState.IdRef="ForEachRow_1">
      <ui:ForEachRow.Body>
        <ActivityAction x:TypeArguments="sd:DataRow">
          <ActivityAction.Argument>
            <DelegateInArgument x:TypeArguments="sd:DataRow" Name="row" />
          </ActivityAction.Argument>
          <Sequence DisplayName="Body" sap:VirtualizedContainerService.HintSize="376,344" sap2010:WorkflowViewState.IdRef="Sequence_7">
            <sap:WorkflowViewStateService.ViewState>
              <scg:Dictionary x:TypeArguments="x:String, x:Object">
                <x:Boolean x:Key="IsExpanded">True</x:Boolean>
              </scg:Dictionary>
            </sap:WorkflowViewStateService.ViewState>
            <ui:NavigateTo Browser="[Browser]" DisplayName="Navigate To" sap:VirtualizedContainerService.HintSize="334,59" sap2010:WorkflowViewState.IdRef="NavigateTo_1" Url="[&quot;https://www.bursamalaysia.com&quot; + row(&quot;Url&quot;).ToString]" />
            <Delay Duration="00:00:05" sap:VirtualizedContainerService.HintSize="334,22" sap2010:WorkflowViewState.IdRef="Delay_1" />
            <ui:LogMessage DisplayName="Log Message" sap:VirtualizedContainerService.HintSize="334,91" sap2010:WorkflowViewState.IdRef="LogMessage_3" Level="Info" Message="[&quot;Here you do all the stuff like Click Annual Report...&quot;]" />
          </Sequence>
        </ActivityAction>
      </ui:ForEachRow.Body>
    </ui:ForEachRow>
  </Sequence>
</Activity>

推荐阅读