excel - 将数据拉到excel中的工作簿
问题描述
尝试从网站抓取数据时遇到问题。这是运行时错误“424”:需要对象我的代码:
Option Explicit
Sub GetData()
Dim IE As New SHDocVw.InternetExplorer
IE.Visible = True
IE.Navigate "abc.com"
Do While IE.ReadyState <> READYSTATE_COMPLETE
Loop
IE.Document.forms("vinSearchForm").elements("vin").Value =
"******"
IE.Document.forms("vinSearchForm").elements("vinSearch").Click
Sheets("Sheet1").Select
Range("A10").Select
IE.Document.forms("vinSummaryForm").elements
("test_vinSummary_carSpecification_$4").Value = Range("A10").Value
End Sub
我想要的是在范围(“A10”)中显示结果“2004*********”。请相应地帮助我。谢谢。
解决方案
虽然不是最好的方法,但应该为你工作
Option Explicit
Sub Autocheck()
Dim IE As New SHDocVw.InternetExplorer
IE.Visible = True
IE.Navigate "Autocheck.com"
Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy
DoEvents
Loop
Application.Wait Now + TimeSerial(0, 0, 5)
IE.Document.forms("vinSearchForm").elements("vin").Value = "JTDKB22U140021007"
IE.Document.forms("vinSearchForm").elements("vinSearch").Click
Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy
DoEvents
Loop
Application.Wait Now + TimeSerial(0, 0, 5)
Range("A10").Value = Split(IE.Document.getelementbyid("test_vinSummary_carSpecification_$4").innerText, vbNewLine)(1)
IE.Quit
Set IE = Nothing
End Sub
推荐阅读
- python - queryset.values_list 是否再次调用 db?
- javascript - 有什么办法可以避免 localStorage.getItem() 的 key 的未定义值?
- python - 如何在 Django 模型中添加动态 Numpy 数组字段
- pine-script - 错误:“....应该在每次计算中调用以保持一致性。建议从这个范围中提取调用”
- django - 如何让 django 使用弹性 beanstalk 和 apache 在 https 上工作?
- azure-percept - 与 Azure Percept DK 访问点的连接经常断开
- python - 查找重复项并创建映射
- mysql - 如何显示 MySQL 表行中不为空的记录数?
- css - 如何在引导映射中浮动文本
- httpclient - HttpClient Time_wait