简体   繁体   English

如何在 TIDHttp (indy) delphi 上执行 javascript 函数?

[英]How to execute a javascript function on TIDHttp (indy) delphi?

I have a TIDHttp (Indy) component, retrieving a website, from where I get the html text to parse and with the data gathered display into a delphi form.我有一个 TIDHttp (Indy) 组件,它检索一个网站,从中获取要解析的 html 文本并将收集的数据显示为 delphi 表单。

The code is working fine, but when more than 10 records are found, the website shows a link to a Next() javascript function that loads the next 10 records and so on.代码运行良好,但是当找到超过 10 条记录时,网站会显示一个指向 Next() javascript 函数的链接,该函数加载接下来的 10 条记录等等。

Is there something that I can do with TIDHttp in order to execute the next() function ?为了执行 next() 函数,我可以用 TIDHttp 做些什么吗?

The code I'm using to retrieve the html text is as follows:我用来检索 html 文本的代码如下:

procedure TForm1.ObtemStringsCorreio(aParamEntrada:string; var aRetorno:TStringList);
var
    _ParamList : TStringList;
begin
    _ParamList := TStringList.Create;

    _ParamList.Add('cepEntrada=' + aParamEntrada);
    _ParamList.Add('tipoCep=ALL');
    _ParamList.Add('cepTemp=');
    _ParamList.Add('metodo=buscarCep');

    try
        aRetorno.Text := idhtp1.Post(cEngineCorreios, _ParamList);
        mmo1.Lines.Clear;
        mmo1.Text :=  aRetorno.Text;
    finally
        _ParamList.Free;
    end;
end;

Indy is a communications library. Indy 是一个通讯库。 It does not have any means for client side script execution.它没有任何用于客户端脚本执行的方法。 You will need to use another library for that.您将需要为此使用另一个库。

A headless browser would be the ideal solution.无头浏览器将是理想的解决方案。 A more heavyweight solution would be to embed a browser in a hidden form, and get it to do the work.一个更重量级的解决方案是将浏览器嵌入到隐藏形式中,并让它完成工作。 You could use TWebBrowser , Chromium, etc. for this purpose. TWebBrowser ,您可以使用TWebBrowser 、 Chromium 等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM