如何在Delphi自定义浏览器中修改RequestHeaders实现长尾词的请求?

2026-04-10 02:071阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计246个文字,预计阅读时间需要1分钟。

如何在Delphi自定义浏览器中修改RequestHeaders实现长尾词的请求?

我的Deplhi应用程序(IE)中集成了一个浏览器。我需要调用某个Web应用程序,需要在中添加一个新变量,表示来自我的应用程序的浏览器所有请求。例如,将jquery将x_robj添加到HTTP_X_REQUESTED_WITH参数中。

如何在Delphi自定义浏览器中修改RequestHeaders实现长尾词的请求?

我的deplhi应用程序(IE)中集成了一个浏览器.我需要调用某个Web应用程序,我需要在标题中为来自我的应用程序浏览器的所有请求添加一个新变量,例如 jquery将x_robj添加到HTTP_X_REQUESTED_WITH参数.我怎么能这样做呢?代码样本会很棒.我是TWebBrowser的用户. 您可以使用OnBeforeNavigate2事件修改标头:

procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject; const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData, Headers: OleVariant; var Cancel: WordBool); var NewHeaders: OleVariant; begin // do not allow frames or iframes to raise this event if (pDisp as IUnknown) = (WebBrowser1.ControlInterface as IUnknown) then begin // avoid stack overflow: check if our custom header is already set if Pos('MyHeader', Headers) <> 0 then Exit; // cancel the current navigation Cancel := True; (pDisp as IWebBrowser2).Stop; // modify headers with our custom header NewHeaders := Headers + 'MyHeader: Value'#13#10; (pDisp as IWebBrowser2).Navigate2(URL, Flags, TargetFrameName, PostData, NewHeaders); end; end;

本文共计246个文字,预计阅读时间需要1分钟。

如何在Delphi自定义浏览器中修改RequestHeaders实现长尾词的请求?

我的Deplhi应用程序(IE)中集成了一个浏览器。我需要调用某个Web应用程序,需要在中添加一个新变量,表示来自我的应用程序的浏览器所有请求。例如,将jquery将x_robj添加到HTTP_X_REQUESTED_WITH参数中。

如何在Delphi自定义浏览器中修改RequestHeaders实现长尾词的请求?

我的deplhi应用程序(IE)中集成了一个浏览器.我需要调用某个Web应用程序,我需要在标题中为来自我的应用程序浏览器的所有请求添加一个新变量,例如 jquery将x_robj添加到HTTP_X_REQUESTED_WITH参数.我怎么能这样做呢?代码样本会很棒.我是TWebBrowser的用户. 您可以使用OnBeforeNavigate2事件修改标头:

procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject; const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData, Headers: OleVariant; var Cancel: WordBool); var NewHeaders: OleVariant; begin // do not allow frames or iframes to raise this event if (pDisp as IUnknown) = (WebBrowser1.ControlInterface as IUnknown) then begin // avoid stack overflow: check if our custom header is already set if Pos('MyHeader', Headers) <> 0 then Exit; // cancel the current navigation Cancel := True; (pDisp as IWebBrowser2).Stop; // modify headers with our custom header NewHeaders := Headers + 'MyHeader: Value'#13#10; (pDisp as IWebBrowser2).Navigate2(URL, Flags, TargetFrameName, PostData, NewHeaders); end; end;