VBA和IE8-输入值并搜索 [英] VBA and IE8 - enter value and search

查看:159
本文介绍了VBA和IE8-输入值并搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于Intranet的网站正在工作,我想输入SKU并使用VBA和IE8将数据收集到excel工作表中.当前正在等待Access许可证批准和批准,以获取对我们的IBM as400服务器的访问权限. IE8不支持getElementsByName,并且搜索栏没有ID,因此我在网上找到的大多数示例都不相关.

I have an intranet based website at work that I'd like to input SKU's and scrape the data that comes up into an excel sheet using VBA and IE8. Currently waiting on Access license approvals and approval to gain access to our IBM as400 server. IE8 does not support getElementsByName, and the search bar has no ID, so most of the examples I've found online aren't relevant.

Sub scraper()

Dim item As Long

item = "10011" 'this will eventually be placed in a loop for multiple searches

Set objIE = CreateObject("InternetExplorer.Application")
  objIE.Visible = True
' navigate and download the web page
  objIE.Navigate "http://**********.aspx"
Do While objIE.ReadyState <> 4 Or objIE.Busy
    DoEvents
Loop

objIE.document.getElementsByName("input").Value = item


End Sub

这是被检查的元素树的照片.如您所见,只有名称(输入)和类(st1),没有ID.我如何才能将搜索数据输入到该区域?尽管我确实也可以使用Chrome,但我仍然坚持使用IE8 ...

Here's a photo of the inspected element tree. As you can see, there is only a name (input) and class (st1), no ID. How can i get the search data input into this area? I am stuck with IE8, although I do have access to Chrome as well...

推荐答案

objIE.document.getElementsByName("input").Value = item更改为objIE.document.getElementsByTagName("input")(0).Value = item最终解决了此问题.

Changing objIE.document.getElementsByName("input").Value = item to objIE.document.getElementsByTagName("input")(0).Value = item ended up resolving this issue.

getElementsByTagName.

getElementsByTagName is supported by IE8.

这篇关于VBA和IE8-输入值并搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆