【发布时间】:2018-03-05 16:53:20
【问题描述】:
我正在尝试从列表中获取特定项目的数据排名。 示例-Morpheus Greens 项目位于列表中的数据排名第 11 位。如下图所示。我想要范围 A1 中的数据排名计数 11。 以下是我尝试过但没有运气的 vba 代码。
图片-
我的 vba 代码-
Sub Class_Initialize()
Set driver = CreateObject("Selenium.FirefoxDriver")
driver.get "https://www.99acres.com/search/project/buy/residential/sector-78-noida?search_type=QS&search_location=CP1&lstAcn=CP_R&lstAcnId=1&src=CLUSTER&preference=S&selected_tab=3&city=7&res_com=R&isvoicesearch=N&keyword_suggest=sector-78%20noida%3B&np_search_type=R2M%2CNL%2CNP&fullSelectedSuggestions=sector-78%20noida&strEntityMap=W3sidHlwZSI6ImxvY2FsaXR5In0seyIxIjpbInNlY3Rvci03OCBub2lkYSIsIkNJVFlfNywgTE9DQUxJVFlfODM5OCwgUFJFRkVSRU5DRV9TLCBSRVNDT01fUiJdfV0%3D&texttypedtillsuggestion=sector&refine_results=Y&Refine_Localities=Refine%20Localities&action=%2Fdo%2Fquicksearch%2Fsearch&suggestion=CITY_7%2C%20LOCALITY_8398%2C%20PREFERENCE_S%2C%20RESCOM_R&searchform=1&locality=8398&price_min=null&price_max=null"
driver.Window.Maximize
driver.Wait 2000
driver.FindElementByXPath("//a[contains(@class,'npt_titl_desc')][contains(text(),'Morpheus Greens')]").ScrollIntoView
driver.FindElementByXPath("//a[contains(@class,'npt_titl_desc')][contains(text(),'Morpheus Greens')]").Size = Range("A1")
'My output should 11
End Sub
【问题讨论】: