Я новичок в VBA. Я пытался очистить сайт для данных о кораблях. Итак, я написал (ну, в основном, скопировал) некоторый скрипт, я дошел до того, что могу печатать правильные результаты в окне «Немедленно», но не для того, чтобы преуспеть. Я sh, чтобы напечатать те же результаты в Excel. Я чувствую, что ответ рядом, но я изо всех сил и не могу заставить его работать.
Сценарий:
Sub Scrape()
'Get ship info
Dim ie As InternetExplorer
Dim html As MSHTML.HTMLDocument
Dim HTMLSCRAPE As MSHTML.IHTMLElementCollection
Dim HTMLSCR As MSHTML.IHTMLElement
Set ie = New InternetExplorer
ie.Visible = False
ie.navigate "https://www.marinetraffic.com/en/ais/details/ships/shipid:5081/mmsi:230352000/vessel:MARJATTA"
Do While ie.readyState <> READYSTATE_COMPLETE
Application.StatusBar = "Trying to go to StackOverflow ..."
DoEvents
Loop
Set html = ie.document
Set HTMLSCRAPE = html.getElementsByTagName("div")
i = 0
For Each HTMLSCR In HTMLSCRAPE
Debug.Print HTMLSCR.className, HTMLSCR.tagName, HTMLSCR.ID, HTMLSCR.innerText
Next HTMLSCR
Set ie = Nothing
Application.StatusBar = ""
End Sub
И вывод в непосредственном окне:
ATD: 2020-01-22 09:34 LT (UTC +1)
ETA: 2020-01-24 01:30 LT (UTC +1)
PAST TRACK
ROUTE FORECAST
Reported ETA: 2020-01-24 01:30 LT (UTC +1)
Calculated ETA: ••••••••••
Calculated ETA at: ••••••••••
Predictive ETD: ••••••••••
Reported Destination: SEHEL
Distance Travelled: ••••••••••
Distance to Go: ••••••••••
Total Voyage Distance: ••••••••••
Time to Destination: ••••••••••
Draught (Reported/Max): 6.8 m / ••••••••••
Load Condition: ••••••••••
Speed recorded (Max / Average): 19 knots / 18.7 knots
VOYAGE TIMELINEPOSITION HISTORY
Reported Destination and ETA Received 2020-01-22 14:40 UTC
UNLOCK VOYAGE INFORMATION
Summary
Where is the ship?
General Cargo MARJATTA is currently located at UKC - North Sea at position 54° 46' 17.328" N, 5° 48' 27.821" E as reported by MarineTraffic Terrestrial Automatic Identification System on 2020-01-22 21:15 UTC (39 minutes ago)
The wind in this area at that time blows from West direction at force 2 Beaufort.
Where is this vessel going to?
The vessel departed from ROTTERDAM BOTLEK, NL on 2020-01-22 09:34 LT (UTC +1) and is currently sailing at 14.7 knots with Northeast direction heading to HELSINGBORG, SE with reported Estimated Time of Arrival at 2020-01-24 01:30 LT (UTC +1) local time (in 1 day, 2 hours )
What kind of ship is this?
MARJATTA (IMO: 9126247) is a General Cargo that was built in 1996 (24 years ago) and is sailing under the flag of Finland.
It’s carrying capacity is 6410 t DWT and her current draught is reported to be 6.8 meters. Her length overall (LOA) is 119.84 meters and her width is 17.9 meters.
Latest Position
Position Received: 2020-01-22 21:15 UTC
39 minutes ago
Vessel's Local Time:
2020-01-22 21:15 LT UTC
Area: UKC - North Sea
Current Port: -
Latitude / Longitude: 54.77148° / 5.807728°
Status: Underway using Engine
Speed/Course: 14.7 kn / 33 °
AIS Source: 2701 Esvagt Alpha
NEARBY VESSELS
SHOW ON LIVE MAP
Weather
Wind: 4 knots
Wind direction: W (282°)
Air Temperature: 9°C
DIV wootric-area
jss4 DIV
TermsPrivacyUser AgreementAbout
English (EN)MarineTraffic BlogHelp Centre
© Copyright 2007 - 2020 MarineTraffic.com
jss5 DIV
TermsPrivacyUser AgreementAbout
English (EN)MarineTraffic BlogHelp Centre
© Copyright 2007 - 2020 MarineTraffic.com
jss6 DIV
TermsPrivacyUser AgreementAbout
English (EN)MarineTraffic BlogHelp Centre
DIV
jss8 DIV TermsPrivacyUser AgreementAbout
English (EN)MarineTraffic BlogHelp Centre
jss79 DIV TermsPrivacyUser AgreementAbout
jss13 DIV © Copyright 2007 - 2020 MarineTraffic.com
DIV MTLoader-1
DIV
DIV
DIV
Как мне получить этот же вывод, чтобы превзойти в разных строках?
РЕДАКТИРОВАТЬ: каждый раз, когда я запускаю этот скрипт, результаты, кажется, отличаются.