excel - Parse HTML in VBA to extract information from description list? -


I want to remove information from the website with Excel XP

I have some examples to the code () and the following:

  function as strHtmlElementValue (htmldoc HTMLDocument, ID as a string) String Dim HtmlElement Set as IHTMLElement in HtmlElement = htmldoc.getElementById (ID) strHtmlElementValue = ID & amp; ":" & Amp; HtmlElement.innerText End Function   

I tried it with the following URL ( htmldoc loaded as):

If I The use of the string "open busted for id", gives the title of the function page, which is fine.

But how can I use E. G. Information like price? In

HTML code, it seems there is no ID and if I getElementById the class name to try to use "is24qa-kaufpreis", I get an error message < / P>

 . & Lt; DL & gt; & Lt; DT & gt; & Lt; Strong class = "is24qa-kaufpreis-label" & gt; Kaufpreis: & lt; / Strong> & Lt; / Dt & gt; & Lt; Dd class = "is24qa-kaufpreis" & gt; 2.190.000,00 EUR & lt; / Dd> & Lt; / DL & gt;   

So, there is a way to reach such areas as "is24qa-kaufpreis" and read the internal text (in this case 2.190.000,00 EUR ?

You can see many different ways about it., Approach based on "getElementsByTagName In the source code for the web page, if you can trust the div of the "DD" in kaufpreis, then you can use the first method. A more general approach is to show it below Is.

  Sub test () my_url = "http://www.immobilienscout24.de/expose/73940554" html_doc set = CreateObject ( "htmlfile") xml_obj set = CreateObject ( "MSXML2 .XMLHTTP ") xml_obj .Open" GET ", my_url, false xml_obj.send html_doc.body.innerhtml = xml_obj.responseText set xml_obj = nothing k_pice = html_doc.body.getElementsByTagName (" dd ") (0) .innertext ' or set result = html_doc.body .getElementsByTagName ( "to each itm DD") results if InStr (1, itm.outerhtml, "E UR", vbTextCompare) & gt; 0 then exit k_price = itm.innertext for the other end if the next ending sub    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -