Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/467.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Excel VBA的Javascript中的提交按钮_Javascript_Excel_Vba_Internet Explorer_Web Scraping - Fatal编程技术网

使用Excel VBA的Javascript中的提交按钮

使用Excel VBA的Javascript中的提交按钮,javascript,excel,vba,internet-explorer,web-scraping,Javascript,Excel,Vba,Internet Explorer,Web Scraping,我似乎无法提交,请单击“提交”或“转到”按钮。它似乎是在javascript下,我不知道如何输入代码来单击go按钮。以下是我所拥有的: Sub FactFinderForm() Dim IE As Object Set IE = CreateObject("InternetExplorer.Application") 'create new instance of IE. use reference to return current open IE if 'you want to use op

我似乎无法提交,请单击“提交”或“转到”按钮。它似乎是在javascript下,我不知道如何输入代码来单击go按钮。以下是我所拥有的:

Sub FactFinderForm()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
'create new instance of IE. use reference to return current open IE if
'you want to use open IE window. Easiest way I know of is via title bar.
IE.Navigate "http://factfinder.census.gov/faces/nav/jsf/pages/index.xhtml###"
'go to web page listed inside quotes
IE.Visible = True

While IE.busy
DoEvents 'wait until IE is done loading page.
Wend

IE.Document.getElementsByname("cfsearchtextboxmain").Item.innertext = _
              ThisWorkbook.Sheets("sheet1").Range("a1")

While IE.readyState <> 4
DoEvents
Wend

SendKeys "{enter}"

End Sub
Sub-FactFinderForm()
模糊的物体
设置IE=CreateObject(“InternetExplorer.Application”)
'创建IE的新实例。如果需要,请使用引用返回当前打开的IE
'您想使用打开的IE窗口。我知道的最简单的方法是通过标题栏。
即“导航”http://factfinder.census.gov/faces/nav/jsf/pages/index.xhtml###"
'转到引号中列出的网页
可见=真实
趁我忙
DoEvents'等待IE完成加载页面。
温德
IE.Document.getElementsByname(“cfsearchtextboxmain”).Item.innertext=_
此工作簿。工作表(“表1”)。范围(“a1”)
而IE.readyState 4
多芬特
温德
SendKeys“{enter}”
端接头
试试这个:

With IE.Document

    .getElementById("cfsearchtextboxmain").Value = _
          ThisWorkbook.Sheets("sheet1").Range("a1").Value

    .parentWindow.ExecScript "cfMainFormSubmit()"

End With

您还可以使用css选择器以元素为目标

#cfmainsearchform > a
也就是说,
id为
cfmainsearchform
的元素中有一个
标记
#
是id,并且
在()

ie.document.querySelector("#cfmainsearchform > a").Click