我对所有编码(学术/心理学家)都很陌生,我试图从这个网站提取数据来创建我的own local database。
我的方法(我无法找到“全部列出”功能)一直在查询英国邮政编码区,即AB1,see here使用从VBA中的几个来源编译的代码(见下文)。
Sub GetCourseList()
Dim URL As String
Dim qt As QueryTable
Dim ws As Worksheet
Set ws = Worksheets.Add
URL = "https://register.fca.org.uk/shpo_searchresultspage?search=AB1&TOKEN=3wq1nht7eg7tr"
Set qt = ws.QueryTables.Add( _
Connection:="URL;" & URL, _
Destination:=Range("A1"))
With qt
.RefreshOnFileOpen = True
.Name = "CoursesFromWiseOwl"
.FieldNames = True
.WebSelectionType = xlAllTables
.Refresh BackgroundQuery:=False
End With
End Sub
我的问题是3折:
excel getdata / webquery / table 1(使用this URL几乎完全符合我的要求,除了它只返回第1页,但我还没有弄清楚如何自动化/缝合代码我想要在一起!
任何人都可以帮我解决这个问题吗?
欢呼声
的Seb
抱歉忘了添加我直接从直接页面直接抓取的原因是使用2种不同类型的个人页面(见下文),似乎在URL中没有任何可预测的ID生成方法。我将编写第二个查询,以相同的方式扫描FCA编号,以便用更完整的数据填充第二个数据库。
(register.fca.org.uk/ShPo_FirmDetailsPage?id = 001b000000MfTlAAAV和
fca-consumer-credit-interim.force.com/CS_RegisterSearchPageNew?accId=210552)
答案 0 :(得分:0)
下面的脚本将为您完成循环。我会留给你做清理工作。提示,提示......使用宏记录器。
Sub GetCourseList()
Dim URL As String
Dim qt As QueryTable
Dim ws As Worksheet
Set ws = Worksheets.Add
Dim lastRow As Long
lastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
variable = 1
Here:
URL = "https://register.fca.org.uk/shpo_searchresultspage?search=AB" & variable & "&TOKEN=3wq1nht7eg7tr"
lastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
Set qt = ws.QueryTables.Add( _
Connection:="URL;" & URL, _
Destination:=Range("A" & lastRow))
With qt
.RefreshOnFileOpen = True
.Name = "CoursesFromWiseOwl"
.FieldNames = True
.WebSelectionType = xlAllTables
.Refresh BackgroundQuery:=False
End With
variable = variable + 1
GoTo Here:
End Sub
我要说的最后一件事就是R会为你做更多,更快,更快。如果我是你,我会用R来做这种事情。