- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
希望从 Barcharts.com 复制股票期权数据并粘贴到 Excel 表中。
Sub CopyTables()
Dim ie As Object
Dim I As Long
I = 0
Set ie = CreateObject("InternetExplorer.Application")
ie.navigate "https://www.barchart.com/stocks/quotes/GOOG/options?moneyness=allRows&view=sbs&expiration=2018-02-23"
ie.Visible = True
Do While ie.Busy And Not ie.readyState = 4
DoEvents
Loop
DoEvents
Set tables = ie.document.getElementsByTagName("table")
SetDataFromWebTable tables, Range("B5")
ie.Quit
End Sub
最佳答案
网页源 HTML 由提供的链接提供
https://www.barchart.com/stocks/quotes/GOOG/options?moneyness=allRows&view=sbs&expiration=2018-02-23
不包含必要的数据,它使用 AJAX。网站https://www.barchart.com有可用的 API。响应以 JSON 格式返回。导航页面 e. G。在 Chrome 中,然后打开开发人员工具窗口 (F12)、网络选项卡、重新加载 (F5) 页面并检查记录的 XHR。最相关的数据是 URL 返回的 JSON 字符串:
https://core-api.barchart.com/v1/options/chain?symbol=GOOG&fields=optionType%2CstrikePrice%2ClastPrice%2CpercentChange%2CbidPrice%2CaskPrice%2Cvolume%2CopenInterest&groupBy=strikePrice&meta=field.shortName%2Cfield.description%2Cfield.type&raw=1&expirationDate=2018-02-23
您可以使用下面的 VBA 代码来检索如上所述的信息。 进口 JSON.bas模块到 VBA 项目中进行 JSON 处理。
Option Explicit
Sub Test48759011()
Dim sUrl As String
Dim sJSONString As String
Dim vJSON As Variant
Dim sState As String
Dim aData()
Dim aHeader()
sUrl = "https://core-api.barchart.com/v1/options/chain?" & _
Join(Array( _
"symbol=GOOG", _
"fields=" & _
Join(Array( _
"optionType", _
"strikePrice", _
"lastPrice", _
"percentChange", _
"bidPrice", _
"askPrice", _
"volume", _
"openInterest"), _
"%2C"), _
"groupBy=", _
"meta=" & _
Join(Array( _
"field.shortName", _
"field.description", _
"field.type"), _
"%2C"), _
"raw=1", _
"expirationDate=2018-02-23"), _
"&")
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", sUrl, False
.send
sJSONString = .responseText
End With
JSON.Parse sJSONString, vJSON, sState
vJSON = vJSON("data")
JSON.ToArray vJSON, aData, aHeader
With Sheets(1)
.Cells.Delete
.Cells.WrapText = False
OutputArray .Cells(1, 1), aHeader
Output2DArray .Cells(2, 1), aData
.Columns.AutoFit
End With
End Sub
Sub OutputArray(oDstRng As Range, aCells As Variant)
With oDstRng
.Parent.Select
With .Resize(1, UBound(aCells) - LBound(aCells) + 1)
.NumberFormat = "@"
.Value = aCells
End With
End With
End Sub
Sub Output2DArray(oDstRng As Range, aCells As Variant)
With oDstRng
.Parent.Select
With .Resize( _
UBound(aCells, 1) - LBound(aCells, 1) + 1, _
UBound(aCells, 2) - LBound(aCells, 2) + 1)
.NumberFormat = "@"
.Value = aCells
End With
End With
End Sub
sUrl = "https://core-api.barchart.com/v1/options/chain?" & _
Join(Array( _
"symbol=GOOG", _
"fields=" & _
Join(Array( _
"optionType", _
"strikePrice", _
"lastPrice", _
"percentChange", _
"bidPrice", _
"askPrice", _
"volume", _
"openInterest"), _
"%2C"), _
"groupBy=strikePrice", _
"meta=", _
"raw=0", _
"expirationDate=2018-02-23"), _
"&")
Set vJSON = vJSON("data")
关于json - 打开网页,全选,复制到工作表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48759011/
我希望 CheckboxModel 在呈现网格时显示为全部选中: 这是我的代码: sm = Ext.create('Ext.selection.CheckboxModel', { li
我有一些按钮可以转换为复选框。单击按钮后,我只需将图标更改为复选标记和背景。我在按钮标签后面有一个隐藏的复选框,当单击按钮时该复选框会更新。 我面临的问题是,当我单击“全选”时,该元素的 btn 和图
我有一个 javascipt 如下: if(document.forms[0].Check_All.value=="Select All"){ for (i = 0; i < chk.leng
我有下表: 书 book_id | book_name | book_photo 标题栏 rubric_id | rubric_name 作者 author_id | first_name | las
我看过this这似乎对我的代码没有影响。我试过了 this这似乎只影响第一个复选框,但当我再次单击它时不会取消选中该复选框....我还看到了其他一些我不确定是否完全符合 Rails 风格(或任何术语)
希望从 Barcharts.com 复制股票期权数据并粘贴到 Excel 表中。 Sub CopyTables() Dim ie As Object Dim I As Long
当用户单击 TEdit1 或单击选择其中的某些文本时,如何选择 TEdit1 的所有文本 最佳答案 执行超出 TEdit 控件默认行为的任何操作都可能非常危险。您的用户知道标准 Windows 控件的
我想打开,然后选择 Word 文档中的所有文本,而不是任何属性、格式等。我搜索了该站点并用谷歌搜索了无止境。基本上类似于打开 Word 文档并按 Ctrl-A 并将结果分配给变量。 $word = N
我在表中有带有标签的复选框。我在表“全选”之外添加了一个复选框,ID 为“chkbox”。现在下面的代码工作正常。这是选择和取消选择表中的所有复选框。现在有一些页面由于业务逻辑而禁用了一些复选框。我希
我有以下 list 和任务结构 现在我想如果有人检查一个任务,我想确保检查 list 也得到检查。当有人取消选中 list 时,所有任务都应该取消选中。
我目前正在使用 Footables显示表格数据。每行都有一个复选框。有一个主复选框可以全选。我遇到了一些困难。该表有一个过滤器。当我应用过滤器并尝试选中该过滤器中的所有复选框时,它不起作用。此外,由于
这是我的代码 my $results = $dbh->selectall_hashref('SELECT * FROM sample.teachers where term like "$search
如果您单独单击每个框,则求和部分起作用,但当您单击全选时则不起作用(尽管全选确实会选中所有框) 有什么想法吗? jQuery Example $(document).ready( func
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭
代码如下: function selectAll(obj) { var theTable = obj.parentNode.parentNode.parentNode.p
我正在处理 DB2 上的一些 SQL 查询。是否可以选择表中的所有列并在该选择语句中使用“as”关键字指定某些条件?例如,这个查询是否可行: select *, col1 + col2 as
我正在尝试创建一个 VB 脚本来导航到网站、全选、复制,然后将复制的数据从剪贴板保存到文本文件,但我被卡住了! :( 这是我到目前为止得到的: With CreateObject("InternetE
我的 Shiny 应用中有一个 checkboxGroupInput,代码如下: checkboxGroupInput("sexe", "Sexe:", c("Masculin" = "mas","F
我想覆盖鼠标单击 DataGridView 标题/列单元格(顶部,左侧单元格)的行为。该单元格会导致所有行都被选中。相反,我想阻止它选择所有行。我看到了 RowHeaderSelect 和 Colum
我正在使用 Angular JS 显示来自 REST API 的输出响应(JSON)。我计划为用户提供列出的每个结果的复选框选项以及全选/取消全选复选框。我一直致力于实现全选/取消全选实现、如何实现全
我是一名优秀的程序员,十分优秀!