指定webbrowser的cookie (navigate方法)

netdust 2007-07-08 11:30:33
用webbrowser的navigate方法,可以通过指定参数来改变一些头部信息,比如HTTP_REFERER,但我试过指定cookie,却无法成功,想问一下能否这么指定

我知道一个办法可以成功,但是有些麻烦,是通过调用js脚本来更改cookie
...全文
701 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hao129 2008-03-22
  • 打赏
  • 举报
回复
cookie的问题很多,唉.最近我也是碰到这样一个问题.

请问下如何提交数据到HTTPS里呢?
用WINSOCK 连接 服务器的443端口
但是发送数据后却老是返回Bad Request

有大侠知道的加QQ:303126312 不胜感激!
netdust 2007-07-13
  • 打赏
  • 举报
回复
up
netdust 2007-07-12
  • 打赏
  • 举报
回复
下面是我的测试代码:
var
ov,post: OleVariant;
str: string;
i: integer;
begin
str:='p2=哈哈';
Post := VarArrayCreate([0, (Length(str) - 1)], varByte);
for i := 0 to Length(str) - 1 do
Post[i] := Ord(str[i + 1]);
ov := 'Content-Type:application/x-www-form-urlencoded'+#13#10+'User-Agent:heihei'+#13#10+'COOKIE: ck=haha;';
ie.Navigate('http://test/1.asp?p1=11',EmptyParam,EmptyParam,post,ov);
end;

提交后,根据1.asp可以看到效果,别的参数都可以,但是cookie无效
不知是哪里有错误,还是cookie不允许这样构造
谢谢大家
蒋晟 2007-07-10
  • 打赏
  • 举报
回复
http://msdn2.microsoft.com/EN-US/library/aa385326.aspx
brightyang 2007-07-09
  • 打赏
  • 举报
回复
procedure Navigate(const URL: WideString); overload;
procedure Navigate(const URL: WideString; var Flags: OleVariant); overload;
procedure Navigate(const URL: WideString; var Flags: OleVariant; var TargetFrameName: OleVariant); overload;
procedure Navigate(const URL: WideString; var Flags: OleVariant; var TargetFrameName: OleVariant; var PostData: OleVariant); overload;

procedure Navigate(const URL: WideString; var Flags: OleVariant; var TargetFrameName: OleVariant; var PostData: OleVariant; var Headers: OleVariant); overload;

Description

Use Navigate to locate and download a specific resource. Navigate can send an HTTP message to a specified URL and display the results or simply display the results of a specified file.

URL specifies the UNC path name of a file or the Uniform Resource Locator of an Internet resource that the Web browser should display.

Flags is a set of values that specify whether to add the resource to the history list, whether to read from or write to the cache, and whether to display the resource in a new window. It can be a sum of zero or more of the following:

Constant Value Meaning

navOpenInNewWindow 1 Open the resource or file in a new window.
navNoHistory 2 Do not add the resource or file to the history list. The new page replaces the current page in the list.
navNoReadFromCache 4 Do not read from the disk cache for this navigation.
navNoWriteToCache 8 Do not write the results of this navigation to the disk cache.
navAllowAutosearch 16 If the navigation fails, the Web browser attempts to navigate common root domains (.com, .edu, and so on). If this still fails, the URL is passed to a search engine.

TargetFrameName is the name of the frame in which the resource will be displayed, or NULL if the resource should not be displayed in a named frame.

PostData contains the data sent to the server when using Navigate to generate an HTTP POST message. If PostData is NULL, Navigate generates an HTTP GET message. PostData is ignored if URL does not specify an HTTP URL.

Headers contains any headers sent to the servers when the URL represents an HTTP URL. HTTP headers specify such things as the intended action required of the server, the type of data, and so on. (See TWebRequest object, whose properties represent many of the more common headers).
netdust 2007-07-09
  • 打赏
  • 举报
回复
up

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧