Excel VBA извлекать данные из таблицы веб-сайта - PullRequest
0 голосов
/ 22 октября 2018

Я пытаюсь почистить сайт и мне нужно только 1 значение.Как я могу получить метод покупки, используя код ниже?см HTML ниже

Private Sub CommandButton1_Click()
    Dim IE As Object
    ' Create InternetExplorer Object
    Set IE = CreateObject("InternetExplorer.Application")
    ' You can uncoment Next line To see form results
    IE.Visible = False
    ' URL to get data from
    IE.Navigate Cells(1, 1)
    ' Statusbar
    Application.StatusBar = "Loading, Please wait..."
    ' Wait while IE loading...
    Do While IE.Busy
        Application.Wait DateAdd("s", 5, Now)
    Loop
    Application.StatusBar = "Searching for value. Please wait..."
    Dim tr As Object, td As Object, tb As Object
    Dim value As String

    Set tb = IE.Document.getElementById("prop_desc clearfix")

    For Each tr In tb.Rows 'loop through the <tr> rows of your table
      For Each td In tr.Cells 'loop through the <th> cells of your row
        value = td.outerText 'your value is now in the variable "value"
        MsgBox value
      Next td
    Next tr

    ' Show IE
    IE.Visible = True
    ' Clean up
    Set IE = Nothing
    Application.StatusBar = ""
End Sub

    </div>
  </div>
  <div class="prop_desc clearfix"><div class = "span-half">
  <h3>RV Park/Campground for Sale</h3>
  <table>

    

  <tr>
    <td>Number of RV Lots: </td>
    <td>270</td>
  </tr>


  <tr>
    <td>Size:</td>
    <td>
      157 acre(s)
    </td>
  </tr>




    <tr>
      <td>Purchase Method:</td>
      <td>Cash, New Loan</td>
    </tr>

  <tr>
    <td>Status:</td>
    <td>
      Active
    </td>
  </tr>


  <tr>
    <td>Property ID:</td>
    <td>966994</td>
  </tr>


    <tr>
      <td>Posted on:</td>
      <td>Jul 10, 2018</td>
    </tr>

    <tr>
      <td>Updated on:</td>
      <td>Jul 10, 2018</td>
    </tr>
    <tr>

Ответы [ 2 ]

0 голосов
/ 23 октября 2018

ОБНОВЛЕНИЕ:

Url https://www.rvparkstore.com/rv-parks/902077--2843-lake-frontage-42-acres-for-sale-in-north-central-us

HTML Здесь https://docs.google.com/document/d/1J5tDV99IbzucCB_z8QX8lDa4X3ecxQbQOWeVy5B7Irg/edit?usp=sharing

, пожалуйста, используйте ссылки для получения дополнительной информации

0 голосов
/ 23 октября 2018

Вы можете настроить таргетинг по классам по индексу, а затем по индексу тд.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...