Hi All,
I need help in extracting href inner text values which are in <a title into excel sheet. I have included html code for your reference.
I have also attached the excel file with output that i need in "Hvalues" tab. Macro which i used is mentioned below.
Code
- Sub hvalues()
- Dim r As Long
- Dim ie As InternetExplorer
- Dim doc As HTMLDocument
- Dim Pfumes As IHTMLElementCollection
- Dim fume As HTMLDivElement
- Dim output As Variant
- Set ie = New InternetExplorer
- With ie
- .Visible = True
- .Navigate "https://www.example.com/"
- Do While .Busy Or .READYSTATE <> 4: DoEvents: Loop
- End With
- Set doc = ie.Document
- Set Pfumes = doc.getElementsByClassName("row wo-download-attachments-link")
- ReDim output(1 To Pfumes.Length, 1 To 2)
- For Each fume In Pfumes
- r = r + 1
- output(r, 2) = fume.getElementsByTagName("a")(0).href
- output(r, 1) = LTrim(fume.getElementsByTagName("a")(0).outerText)
- Next
- ie.Quit
- Range("A1:B1") = Array("Product Name", "Link")
- Range("A2").Resize(UBound(output), 2) = output
- ActiveSheet.UsedRange.Columns.AutoFit
- ActiveSheet.UsedRange.Borders.Weight = 2
- ActiveSheet.Range("A1:B1").Interior.ThemeColor = xlThemeColorAccent1
- End Sub
HTML
- <div class="col-sm-3 col-xs-12 pull-right attachments-files-list" id="WorkOrderAttachments">
- <button class="btn btn-success primary wo-attachments-btn js-app-action-el" data-bind="visible: !$root.providerShouldAcceptDecline() && !isOutsourced(), click : addAttachment"><i class="fa fa-plus" aria-hidden="true"></i>Add Attachment</button>
- <div class="row wo-download-attachments-link">
- <a class="btn btn-default" href="#" data-bind="click : downloadAttachments, visible: $root.attachmentsViewModel.attachments().length > 0">
- <i class="fa fa-download js-app-action-el" aria-hidden="true"></i>
- Download <strong data-bind="text:$root.attachmentsViewModel.attachments().length">2</strong> Attachments
- </a>
- </div>
- <div class="wo-attachments-link">
- <a class="js-app-action-el" href="#" data-bind="click: $root.attachmentsViewModel.showDeleteAttachmentDialog"><i class="fa fa-trash-o" aria-hidden="true"></i></a>
- <a title="check_out_2018.02.16_20:12:51.jpg" class="js-app-action-el" style="padding-left: 0px;" href="https://example.com/Documents/GetTempLink?attachmentId=201802%2f5815e207-13ed-40b6-b7f3-c54907c65fa4-check_out_2018.02.16_20%3a12%3a51.jpg&overridefilename=check_out_2018.02.16_20%3a12%3a51.jpg&overrideFileName=check_out_2018.02.16_20%3a12%3a51.jpg" target="_blank" data-bind="text:fileName, attr: { href: url, title: description }, style: { 'padding-left': $parent.isOutsourced() ? 30 : 0 }">check_out_2018.02.16_20:12:51.jpg</a>
- <div class="wo-attachments-link">
- <a class="js-app-action-el" href="#" data-bind="click: $root.attachmentsViewModel.showDeleteAttachmentDialog"><i class="fa fa-trash-o" aria-hidden="true"></i></a>
- <a title="check_out_2018.02.16_20:12:48.jpg" class="js-app-action-el" style="padding-left: 0px;" href="https://example.com/Documents/GetTempLink?attachmentId=201802%2f3f8288b9-6931-412c-a021-615766619fde-check_out_2018.02.16_20%3a12%3a48.jpg&overridefilename=check_out_2018.02.16_20%3a12%3a48.jpg&overrideFileName=check_out_2018.02.16_20%3a12%3a48.jpg" target="_blank" data-bind="text:fileName, attr: { href: url, title: description }, style: { 'padding-left': $parent.isOutsourced() ? 30 : 0 }">check_out_2018.02.16_20:12:48.jpg</a>
Thanks for your help.
TC