Code will enter search term, activate the search but cannot copy the results back. Webpage appears to be Javascripted. Here's my code below: what I've tried previously is commented out. Below that is an example of a search result.
Resulting web page content:Sub GetASTM() ' had to activate library Microsoft HTML object library (MSHTML.TLB) via ' "Tools" > "References". Then get the IHTML items Dim ie As Object Dim Std As Object Dim ElementCol As Object Dim btnInput As Object Dim el, f Dim s As String Dim r As Range Dim Element As IHTMLElement Dim Elements As IHTMLElementCollection Dim doc1 As MSHTML.HTMLDocument Dim xxml As MSXML2.xmlHTTP Set xxml = GetMSXML Set ie = CreateObject("InternetExplorer.Application") With ie .navigate "http://compass.astm.org/CUSTOMERS/fi....cgi?index.frm" .Visible = True End With Do While ie.Busy Loop Set Std = ie.Document.getElementsByName("search") Std(0).Value = "B33" Set el = ie.Document.getElementById("main-search-btn") el.Click Do While ie.Busy Loop .Open ' s = ie.Document.getElementsBy ' s = doc1.body.innerText ' Set Elements = ie.Document.getElementById("var") ' For Each Element In Elements ' Debug.Print Element.innerText' ' Next Element ' s = ie.Document.All("mc_results").innerText ' s = ie.Document.getElementsByName("title").innerText ' Set r = s ' With r.Find ' .Text = "Standard Specification for" ' .Forward = True ' .Wrap = wdFindStop ' .Execute ' End With ' With r ' .MoveEndUntil Cset:=""", Count:=wdForward" ' End With End Sub
The above is the top part of the web page result. Here's what I need to copy:HTML Code:<! DOCTYPE html> < html> <head> <title>ASTM Compass</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta charset="utf-8" /> <link rel="shortcut icon" href="/favicon.ico?v2" /> <link rel="stylesheet" type="text/css" href="/CUSTOMERS/css/combined.css?v1a" /> <!--[if IE]> <link rel="stylesheet" type="text/css" href="/css/ie.css" /> <![endif]--> <!--[if lte IE 7]> <link rel="stylesheet" type="text/css" href="/css/ie-7.css" /> <![endif]--> <script type="text/javascript" src="/CUSTOMERS/js/complete-lite.js?v2a"></script> <script type="text/javascript" src="/CUSTOMERS/search/js/search-lite.js?r3g"></script> <script type="text/javascript">
HTML Code:var mc_results = {"resSet":[ { "results":[{ "res" :{ "url":"http://compass.astm.org/BioDiesel/B33.htm", "title":"Standard Specification for Tin-Coated Soft or Annealed Copper Wire for Electrical Purposes", "snippet":"1 | Scope Previous Next | Top Bottom 1.1 This specification covers tin-coated, round, soft, or annealed copper wire for electrical purposes. 1.2 The values stated in inch-pound units are to be regarded as standard. The values given in parentheses are mathematical conversions to SI units that are provided for information only and are not considered standard. 1.2.1 Exceptions—The ", "meta":{"gs_designation":"B33","mc_section":"02","mc_maincomm":"B01","mc_date":"2014","title":"Standard Specification for Tin-Coated Soft or Annealed Copper Wire for Electrical Purposes","mc_dltype":"allstd,active","mc_doctype":"Active Standard","mc_addtocart":"PDF-B33","gs_year":"10




Reply With Quote
