Hi All,
I need help on the way to get specific data from a web site in to excel using excel VB.
Here is the HTML code of the web site.
My Target is Get the following Item
1. "One Name" (Mark in red and bold) and put it on excel on range ("B1")
2. the link href="/profile.php?id=id_Number&refid=46&fref=search" (Mark in red and bold) and put it on range("C1")
Below is my macro (and giving me something else other then what I want)
Thank you in advance for sort this things out.
Regards,
Benny
I need help on the way to get specific data from a web site in to excel using excel VB.
Here is the HTML code of the web site.
Code:
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;"> [COLOR=#FF0000][SIZE=5][B]< div id="objects_container">[/B][/SIZE][/COLOR]
[COLOR=#FF0000][SIZE=5][B]< div id="objects_container" data-sigil="search-results">[/B][/SIZE][/COLOR]
< div class="_4g33 _52we _5ca3 _5ca1 _ydx">
< div class="_4g34 _195r _5cwg">
< a class="_54k8 _5c9u _5caa" href=
"/search/people/?ssid=anotherNumber&search_source=filter&refid=46&q=somenumber&tsid&o=274"
role="button" data-sigil="touchable">< span class="_55sr">Orang< /span>< /a>
< /div>
< div class="_4g34 _195r _5cwg">
< a class="_54k8 _5c9u _5caa" href=
"/search/pages/?ssid=anotherNumber&search_source=filter&refid=46&q=somenumber&tsid"
role="button" data-sigil="touchable">< span class=
"_55sr">Halaman< /span>< /a>
< /div>
< div class="_4g34 _195r _5cwg">
< a class="_54k8 _5c9u _5caa" href=
"/search/events/?ssid=anotherNumber&search_source=filter&refid=46&q=somenumber&tsid"
role="button" data-sigil="touchable">< span class="_55sr">Acara< /span>< /a>
< /div>
< div class="_4g34 _195r _5cwg">
< a class="_54k8 _5c9u _5caa" href=
"/search/groups/?ssid=anotherNumber&search_source=filter&refid=46&q=somenumber&tsid"
role="button" data-sigil="touchable">< span class="_55sr">Grup< /span>< /a>
< /div>
< /div>
< div>
< div>
< div class="item itemWithAction acw" *******=
"require('MTouchPPSLog').logClick("result_click", "id_Number", 0, 2048);"
data-sigil="undoable-action marea">
< a class="touchable primary" href=
"[COLOR=#FF0000][B][SIZE=5]/profile.php?id=id_Number&refid=46&fref=search[/SIZE][/B][/COLOR]"
data-sigil="touchable">< /a>
< div class="primarywrap">
< div class="image">< /div>
< div class="content">
< div class="title _1i1q mfsl fcb">
< strong>[B][COLOR=#FF0000][SIZE=5]One Name[/SIZE][/COLOR][/B]< /strong>
< /div>
< div class="subtitle fcg">
< div class="_4z0-" id="u_0_2" data-sigil=
"m-friend-request-highlight-notice">
< div class="notice" style="display: none;" data-sigil=
"m-add-friend-request-sent">
Permintaan terkirim
< /div>
< div class="notice ellipsis" data-sigil=
"m-add-friend-source-replaceable">< /div>
< div style="display: none;" class="notice" data-sigil=
"m-friend-request-canceled">
Permintaan dibatalkan
< /div>
< /div>
< /div>
< /div>
< /div></code>
My Target is Get the following Item
1. "One Name" (Mark in red and bold) and put it on excel on range ("B1")
2. the link href="/profile.php?id=id_Number&refid=46&fref=search" (Mark in red and bold) and put it on range("C1")
Below is my macro (and giving me something else other then what I want)
Code:
Sub PullDataFromWeb()
Dim ie As New InternetExplorer
Dim doc As HTMLDocument
ie.Visible = True
ie.navigate "Url link here"
Do
DoEvents
Loop Until ie.readyState = 4
Set doc = ie.document
***strTitle = doc.getElementById("objects_container").getElementsByTagName("Strong")(0).innerText***
'PLEASE CORRECT ME ON THIS PART
'I TRY USING getElementByClassName but come up with error "Object doesn't support this property or method"
MsgBox strTitle
'I haven't assigned it to range("B1") just show it in message box first and if correct then I will do so.
End Sub
Thank you in advance for sort this things out.
Regards,
Benny