如何从父URL中的多个子URL中提取innertext? [英] How can I extract innertext from several child URLs that come from a parent URL?

查看:77
本文介绍了如何从父URL中的多个子URL中提取innertext?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的脚本,点击链接并打开子URL(来自父URL)。



I have the script below, which clicks a link and opens a child URL (from a parent URL).

If link.innerHTML Like "*Upload Questionnaire*" Then
            link.Click

            Set objIE = CreateObject("InternetExplorer.Application")
            objIE.Navigate strURL

            Do While objIE.ReadyState <> 4 And objIE.Busy
               DoEvents
            Loop


                    Set XMLHTTP = CreateObject("MSXML2.XMLHTTP")
                    XMLHTTP.Open "GET", strSQL, False
                    XMLHTTP.send
                    Set html = CreateObject("htmlfile")
                    html.body.innerHTML = XMLHTTP.responseText
                    Set tbl = html.getElementsByTagName("Table")
                    Set tr_coll = tbl(0).getElementsByTagName("TR")
                    For Each tr In tr_coll
                        j = 1
                        Set td_col = tr.getElementsByTagName("TD")
                        For Each td In td_col
                            Cells(row + 1, j).Value = td.innerText
                            j = j + 1
                        Next
                        row = row + 1
                    Next
        End If

首先,代码不会暂停并等待浏览器完成加载。

For one thing, the code doesn't pause and wait for the browser to finish loading.

Do While objIE.ReadyState <> 4 And objIE.Busy
   DoEvents
Loop


< p style ="">另外,我正在输入父URL,如下所示:

Also, I'm feeding in a Parent URL, like this:

strSQL = "https://blah_blah_blah_CampaignID=" & cell.Value


下面的行不起作用。

The line below doesn't work.

XMLHTTP.Open "GET", strSQL, False


不知怎的,我需要传入从父URL打开的子URL。这是父URL:  strSQL
=" https:// blah_blah_blah_CampaignID ="& cell.Value

何时:  link.Click   运行
然后子URL打开,但是我不知道如何引用子URL。我该怎么做?!

When: link.Click runs then the Child URL opens, but I don't know how to reference the Child URL. How can I do that?!




MY BOOK

推荐答案

您好,

由于此问题与Excel对象模型无关且您使用的是VBScript,我建议您发布以下论坛:

Since this issue is not related to Excel object model and you are using VBScript, I suggest you post on the following forum:

https:/ /social.msdn.microsoft.com/Forums/office/en-US/home?forum=scripting

很抱歉给您带来不便。

问候,

Celeste


这篇关于如何从父URL中的多个子URL中提取innertext?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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