我正在尝试使用excel vba抓取Linkedin上人员的姓名和位置。我想出了如何获取姓名及其位置,但仅适用于前12个人。事实是,您需要在网页上滚动才能看到更多人,我认为我只有12个人,因为在加载网页时,它仅考虑网页而不滚动。 因此,我正在寻找一种通过vba滚动页面的方法或其他方法来注册网页(这样我就可以获取所有信息)。
我尝试了一些方法来滚动Internet上的网页,但是它不起作用。
这是我的代码: 子depart()
Dim ie As SHDocVw.InternetExplorer
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLInput As MSHTML.IHTMLElement
Dim HTMLNames As MSHTML.IHTMLElementCollection
Dim HTMLNames1 As MSHTML.IHTMLElementCollection
Dim HTMLName1 As MSHTML.IHTMLElement
Dim HTMLName As MSHTML.IHTMLElement
Dim NRow As Long
Dim NRow1 As Long
NRow1 = 1
Set ie = New SHDocVw.InternetExplorer
ie.Visible = True
ie.navigate "......."
Do While ie.readyState <> READYSTATE_COMPLETE
Loop
Set HTMLDoc = ie.document
Set HTMLNames = HTMLDoc.getElementsByClassName("artdeco-entity-lockup__subtitle ember-view")
Set HTMLNames1 = HTMLDoc.getElementsByClassName("org-people-profile-card__profile-title t-black lt-line-clamp lt-line-clamp--single-line ember-view")
For Each HTMLName In HTMLNames
Worksheets("start").Activate
Cells(NRow, 1) = HTMLName.innerText
NRow = NRow + 1
Next HTMLName
For Each HTMLName1 In HTMLNames1
Worksheets("start").Activate
Cells(NRow1, 2) = HTMLName1.innerText
NRow1 = NRow1 + 1
Next HTMLName1
结束子