【发布时间】:2020-01-23 00:29:14
【问题描述】:
我需要从网站中提取报告并将其导出到 excel。
我可以登录并点击我需要点击的两个 div 中的第一个,但是当我命令 vba 点击第二个 div 时,什么也没有发生。
我是这个行业的新手,我对javascript一无所知,所以如果我说的有问题,请纠正我。
这是有问题的网站:
http://gaps.myeasy.com.br/gaps2010/Spek/Principal.aspx
我需要点击“Gestão”,然后点击“Controle de Atividades”。
到目前为止我的代码:
Sub LoginGaps()
Dim IE As Object
'START INTERNET EXPLORER
Set IE = CreateObject("InternetExplorer.application")
IE.Visible = True
IE.Navigate ("http://gaps.myeasy.com.br/gaps2010/Spek/Principal.aspx")
While IE.Busy Or IE.readyState <> 4: DoEvents: Wend
'LOGIN TO WEBSITE
'frmLogin.Show
'CLICK ON "GESTÃO"
IE.document.getElementById("uwlBar_Group_2_text_top").Click
'CLICK ON "CONTROLE DE ATIVIDADES"
IE.document.getElementById("uwlBar_2_Item_1").Click
End Sub
很遗憾,我无法在论坛中传递用户数据,因为它不是我的,所以我在传递的行前面添加了 '。
即使我不懂 javascript,我也可以理解单击“Controle de atividades”时激活了哪个脚本,但我需要知道“sReturn”的值才能使用“execScript”调用它,由于经验不足,找不到 sReturn 的值。
这是脚本:
function aftermenu(sRetorno)
{
var aRetorno=sRetorno.split("|");
var iModulo=aRetorno[0];
var sId=aRetorno[1];
var sPagina=aRetorno[2];
var sLogin=aRetorno[3];
var iPermissao=aRetorno[4];
if (iPermissao=="1")
{
if (lstItem!=null)
{
lstItem.style.backgroundColor="#f9f9f9";
lstItem.onmouseover=function(){this.style.background="#d6d3d6"};
lstItem.onmouseout=function(){this.style.background="#f9f9f9"};
//lstItem.setSelected(false);
}
lstItem=null;
if (sId!=""){
lstItem=document.getElementById(sId);
lstItem.style.backgroundColor="#dee6f3";
lstItem.onmouseover=function(){};
lstItem.onmouseout=function(){};
/*
lstItem=iglbar_getItemById(sId).element;/*
lstItem.setSelected(true);*/}
frmPrincipal=document.getElementById("frmPrincipal");
frmPrincipal.location.href=sPagina;
}
else
{
showmessage("Acesso ao módulo/função não permitido para o usuário "+sLogin+".\nConsulte o administrador do sistema.",520,constInfo,constOk,this,false);
}
}
脚本将 sRetorno 的值分成 5 个变量,然后在页面上的大方块“frmPrincipal”中打开一个链接,这个链接就是我找到报告的地方。 如果你能帮我找到 sRetorno 的值是如何定义的,我想到了 2 种可能性。
第一种是使用“execScript”调用脚本,第二种是获取 sPagina 的值,如果可能,直接打开链接以提取报告。
重要的是,该站点仅在 Internet Explorer 上运行,这让我更难调试代码并了解 sReturn 的赋值位置。
很抱歉在星期天中间打扰你,但我从星期四开始一直在四处转悠,试图解决这个问题,我就是一动不动。
非常感谢你们。
【问题讨论】:
标签: javascript html excel vba web-scraping