使用Delphi打开URL

发布于 2024-09-10 11:44:10 字数 331 浏览 2 评论 0原文

我正在为朋友做点小事(或者至少我希望这没什么),但已经有 10 年左右没有使用过 Delphi...而且我的搜索并没有多大用处

我在做什么尝试做的就是获取一个 URL,然后解析 HTML 以找到他需要的一些信息。我希望有这样的东西(在 python 中) fileHandle = urllib2.urlopen(urlStr) 并且 fileHandle 会收到我请求的页面的 HTML。我发现的所有示例都打开了默认浏览器,但

我使用的是 Linux、Lazarus 和 Free Pascal,他使用的是 Delphi 7(如果我没记错的话),如果这很重要的话。

谢谢。

I'm doing a little (or at least I'm hoping it's little) favor for a friend, but haven't used Delphi in 10 or so years... and my searches haven't been of much use

What I'm trying to do is to GET an URL and then parse the HTML to find some info he needs. I'm hoping for something like this (in python) fileHandle = urllib2.urlopen(urlStr) and fileHandle would receive the HTML of the page I requested. All examples I found opened the default browser, but

I'm using linux, with Lazarus and Free Pascal, he is using Delphi 7 (if I recall correctly) if that matters at all.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

青柠芒果 2024-09-17 11:44:10

使用 Indy,您可以使用 TidHttp 组件。

var
  http : TidHttp;
  page : String;
begin
  http := TidHttp.Create(nil);
  try
  page := http.get(URL);
  finally 
    http.Free;
  end;
end;

如果您需要其他格式的内容并需要传递附加信息,Get 有多个重载版本。

Using Indy you can use the TidHttp Component.

var
  http : TidHttp;
  page : String;
begin
  http := TidHttp.Create(nil);
  try
  page := http.get(URL);
  finally 
    http.Free;
  end;
end;

Get has several overloaded versions if you desired the contents in other formats and need to pass additional informaiton.

初见 2024-09-17 11:44:10

选项:

  1. 调用 wget(您必须在 Windows 上安装)将页面下载到文本文件,然后将其打开。

  2. 如果您想完全在 Delphi 中完成,请使用 Indy 或 Synapse。

(我一直使用 Synapse 来做这类事情)。

Options:

  1. Call wget (which you will have to install on Windows) to download the page to a text file and then open that.

  2. Use Indy or Synapse if you want to do it entirely in Delphi.

(I use Synapse to do this type of thing all the time).

困倦 2024-09-17 11:44:10

在您的应用中使用 TWebbrowser。
您可以获取文本框的值或单击页面中的按钮。

var
  ovElements: OleVariant;
  i: Integer;
begin
  ovElements := WebBrowser1.OleObject.document.Forms.item(0).elements;
  for i := 0 to (ovElements.Length - 1) do
    if (ovElements.item(i).Name = 'ASPxButton1') 

      (ovElements.item(i).Name = 'ASPxButton1') then
      ovElements.item(i).Click;

或者

WebBrowser1.OleObject.document.Forms.item(0)
        .elements.item
        ('ASPTEXTBOXNAME').value;

Use a TWebbrowser in your app.
You can get the value of textbox or click a button in the page.

var
  ovElements: OleVariant;
  i: Integer;
begin
  ovElements := WebBrowser1.OleObject.document.Forms.item(0).elements;
  for i := 0 to (ovElements.Length - 1) do
    if (ovElements.item(i).Name = 'ASPxButton1') 

      (ovElements.item(i).Name = 'ASPxButton1') then
      ovElements.item(i).Click;

OR

WebBrowser1.OleObject.document.Forms.item(0)
        .elements.item
        ('ASPTEXTBOXNAME').value;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文