单击“通过悬停VBA”

时间:2016-03-11 08:54:34

标签: javascript html excel vba web-scraping

我已成功登录了。坚持能够点击悬停图像/文本。我可以使用基本网址和下面的源代码中提供的href来导航,但我必须再次输入登录信息。此外,此网址导航的网页具有与VBA网址不同的用户名和密码字段。

请参阅下面的当前VBA代码。

    Sub copyshoeprice()

    Dim ie As Object

    Set ie = CreateObject("InternetExplorer.Application")

    With ie

     .Visible = True
     .navigate ("https://data.terapeak.com/verify/")

    While ie.ReadyState <> 4
    DoEvents
    Wend

      ie.document.getelementbyid("username").Value = "xxxxxxxxxx"
      ie.document.getelementbyid("password").Value = "xxxxxxxxxx"

      Set the_input_elements = ie.document.getelementsbytagname("button")
      For Each input_element In the_input_elements
      If input_element.getAttribute("name") = "login" Then
      input_element.Click
       Exit For
       End If
     Next input_element

    End With

    Set ie = Nothing

    End Sub

请参阅需要点击的图片/文字来源。

    <a class="js-features-page usage-logging-enabled" href="page=marketAnalysis" data-page="marketAnalysis" data-access="marketAnalysis">
       <div class="content">
          <div class="icon delayp1">
              <i class="tp-icon-binoculars"></i>
          </div>
       <h3 class="title">
          In-Depth
          <br>
          Research
       </h3>
       <div class="tp-info">
          <span class="choice-text">Analyze products, categories, and trends</span> 
          <span class="Select hidden-sm">Select >> </span>

1 个答案:

答案 0 :(得分:0)

Sub copyshoeprice()

Dim ie As Object
Dim shoe_name_range As Range

Set ie = CreateObject("InternetExplorer.Application")


ie.Visible = True
ie.navigate ("https://sell.terapeak.com/?page=eBayProductResearch#productResearch/item_browse")


Do While ie.readyState <> READYSTATE_COMPLETE
DoEvents
Loop


Set UserN = ie.document.getElementsByName("username")
If Not UserN Is Nothing Then
UserN(0).Value = "xxxxxxxx"
End If


Set PW = ie.document.getElementsByName("password")
If Not PW Is Nothing Then
PW(0).Value = "xxxxxxx"
End If


Set the_input_elements = ie.document.getElementsByTagName("input")
For Each input_element In the_input_elements
If input_element.getAttribute("name") = "login" Then
input_element.Click
Exit For
End If
Next input_element


Do While ie.readyState <> READYSTATE_COMPLETE
DoEvents
Loop


PauseTime = 6
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop


Set ElementCol1 = ie.document.getElementsByTagName("li")
For Each ele1 In ElementCol1
    If ele1.getAttribute("data-i18n") = "DatePicker.NinetyDays" Then
        ele1.Click
Exit For
End If
Next ele1

Set ie = Nothing

End Sub