post一个网址怎么得到返回地址或返回内容(200分)

  • 主题发起人 主题发起人 tzlaoliu
  • 开始时间 开始时间
T

tzlaoliu

Unregistered / Unconfirmed
GUEST, unregistred user!
各位大富翁
小弟最近在弄一个自动登陆易趣的玩意,我已经搞明白他的登陆方式
http://signin.ebay.com.cn/ws/eBayISAPI.dll?SignInWelcome&siteid=223&co_partnerId=2&UsingSSL=0&ru=&pp=&pa1=&pa2=&pa3=&i1=-1&pageType=-1&userid=用户名&pass=密码
3个问题
1,我用WebBrowser提交这个地址提示说浏览器不支持缓存(这个不重要,只要能得到提示不支持缓存的地址就可以,因为这个时候说明用户和密码验证成功)这个方法好像太慢了.
2,idhttp可以实现这个功能吗?我就是想在post这个地址后用最短的时间得到返回的地址或内容
3,能给个参考代码的另加100分答谢
联系我
QQ:65625425 E-mail:tzlaoliu@163.com
 
没有人看吗?
我出300分了
 
unit frmGetInfo;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, StdCtrls, IdAntiFreezeBase, IdAntiFreeze, ComCtrls, ExtCtrls, DB,
MemDS, DBAccess, MyAccess;

type
TProgressInfo=record
Verify_Code:string;//核对码
Accept_case_code:string;//受理号
Corp_name:string;//企业名称
Transact_State:string;//办理状态
Drug_Approve_Code:string;//药品批准文号
State_date:string;//状态开始时间
Notice_date:string;//通知时间
Notice_content:string;//通知内容
Charge_Circs:string;//收费情况
Charge_date:string;//费用收到日期
Checkout_report_date:string;//检验报告收到日期
Criterion_hodometer_date:string;//标准品回执收到日期
end;

type
TGetInfo = class(TForm)
http: TIdHTTP;
btnSearch: TButton;
IdAntiFreeze1: TIdAntiFreeze;
ProgressBar1: TProgressBar;
GroupBox1: TGroupBox;
edtVerify_Code: TLabeledEdit;
edtAccept_case_code: TLabeledEdit;
edtCorp_name: TLabeledEdit;
edtTransact_State: TLabeledEdit;
edtDrug_Approve_Code: TLabeledEdit;
edtState_date: TLabeledEdit;
edtNotice_date: TLabeledEdit;
edtNotice_content: TLabeledEdit;
edtCharge_Circs: TLabeledEdit;
edtCharge_date: TLabeledEdit;
edtCheckout_report_date: TLabeledEdit;
edtCriterion_hodometer_date: TLabeledEdit;
btnClose: TButton;
procedure httpWorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure httpWork(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
procedure btnSearchClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
private
{ Private declarations }
FResultInfo:TProgressInfo;
FSuccess:boolean;
procedure DoSetEditValue;
public
{ Public declarations }
Verify_Code:string;
function CheckConnection(sURL:string):boolean;
function GetProgressInfo(sVerify_Code:string):TProgressInfo;
function SaveToDb(aMyQuery:TMyQuery):boolean;
end;

resourcestring
PostURL=’http://app1.sda.gov.cn/webportal/portal.po?UID=DWV1_WOUID_URL_6646923&&hsearchOption=clientSearch&hsearchSubOption=searchResult’;
UpdateSql=’update Corp_reg_Config set Accept_case_code=’’%s’’,Corp_name=’’%s’’,Transact_State=’’%s’’,’+
’Drug_Approve_Code=’’%s’’, State_date=’’%s’’,Notice_date=’’%s’’,Notice_content=’’%s’’,Charge_Circs=’’%s’’,’+
’Charge_date=’’%s’’,Checkout_report_date=’’%s’’,Criterion_hodometer_date=’’%s’’ ’+
’where Verify_Code=’’%s’’’;

var
GetInfo: TGetInfo;

implementation

{$R *.dfm}

{ TGetInfo }

function TGetInfo.CheckConnection(sURL: string): boolean;
begin
result:=false;
try
http.Head(sURL);
if pos(’200 OK’, http.Response.ResponseText)>0 then
result:=true;
except
end;
end;

function TGetInfo.GetProgressInfo(sVerify_Code: string): TProgressInfo;
var
sHead, sResult: TStringStream;
sResultContent:String;
Inicial,Final: Integer;
function GetValue:string; //取得 ’</SPAN>’ 之前的字符串
var
t:integer;
begin
delete(sResultContent,1,pos(’<SPAN id=&quot;Content&quot;>’,sResultContent)+18);
result:=’’;
t:=pos(’</SPAN>’,sResultContent);
result:=copy(sResultContent,1,t-1);
end;
begin
//检查地址是否有效
if not CheckConnection(PostURL) then
begin
application.MessageBox(’连接服务器失败,请检查网络是否连通!’,’失败’,MB_ICONWARNING);
exit;
end;
FSuccess:=false;
sHead := TStringStream.Create(’’);
sResult := TStringStream.Create(’’);
sHead.WriteString(’ListSelect=TBL_TABLE283&searchClient=’+sVerify_Code);
http.Request.ContentType := ’application/x-www-form-urlencoded’;
try
http.Post(PostURL, sHead, sResult)
except
http.Get(http.Response.Location, sResult);
end;
Inicial := Pos(’<TABLE><TR><TD><SPAN id=&quot;Message&quot;>’,sResult.DataString); //获得返回结果表格字符串的开头
Final : = Pos(’</TD></TR></TABLE></FORM></TD></TR> </TABLE></DIV>’,sResult.DataString); //获得结果表格的结尾
sResultContent := Copy(sResult.DataString,Inicial,Final-Inicial);
sResultContent:= Utf8Toansi(sResultContent);
if Pos(’<SPAN id=&quot;dbDescr&quot;>’,sResultContent)>0 then //如果找到
begin
with Result do
begin
Verify_Code:=sVerify_Code;//核对码
Accept_case_code:=GetValue; //受理号
Corp_name:=GetValue; //企业名称
Transact_State:=GetValue; //办理状态
Drug_Approve_Code:=GetValue; //药品批准文号
State_date:=GetValue; //状态开始时间
Notice_date:=GetValue; //通知时间
Notice_content:=GetValue; //通知内容
Charge_Circs:=GetValue; //收费情况
Charge_date:=GetValue; //费用收到日期
Checkout_report_date:=GetValue; //检验报告收到日期
Criterion_hodometer_date:=GetValue; //标准品回执收到日期
end;
FSuccess:=true;
end
else
begin
application.MessageBox(’没有找到要查询的数据’,’失败’,MB_ICONWARNING);
end;
end;

procedure TGetInfo.httpWorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
begin
ProgressBar1.Position :=0;
ProgressBar1.Max :=AWorkCountMax;
end;

procedure TGetInfo.httpWork(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
ProgressBar1.Position :=AWorkCount;
end;

function TGetInfo.SaveToDb(aMyQuery: TMyQuery): boolean;
begin
result:=false;
if FSuccess then
begin
with aMyQuery do
begin
close;
sql.Clear;
with FResultInfo do
sql.Text :=format(UpdateSql,[Accept_case_code,Corp_name,Transact_State,Drug_Approve_Code,State_date,
Notice_date,Notice_content,Charge_Circs,Charge_date,Checkout_report_date,
Criterion_hodometer_date,Verify_Code]);
try
Execute;
result:=true;
except
result:=false;
end;
end;
end
end;

procedure TGetInfo.DoSetEditValue;
begin
FResultInfo:=GetProgressInfo(Verify_Code);
with FResultInfo do
begin
edtVerify_Code.Text:=Verify_Code;
edtAccept_case_code.Text:=Accept_case_code;
edtCorp_name.Text:=Corp_name;
edtTransact_State.Text:=Transact_State;
edtDrug_Approve_Code.Text:=Drug_Approve_Code;
edtState_date.Text:=State_date;
edtNotice_date.Text:=Notice_date;
edtNotice_content.Text:=Notice_content;
edtCharge_Circs.Text:=Charge_Circs;
edtCharge_date.Text:=Charge_date;
edtCheckout_report_date.Text:=Checkout_report_date;
edtCriterion_hodometer_date.Text:=Criterion_hodometer_date;
end;
end;

procedure TGetInfo.btnSearchClick(Sender: TObject);
begin
Verify_Code:=’1’; //要查询的值,由外部调用者传进来。
//从服务器查询
(Sender as TButton).Enabled :=false;
try
DoSetEditValue;
finally
(Sender as TButton).Enabled :=true;
end;
{
//保存
if SaveToDb() then
begin
application.MessageBox(’保存数据完成!’,’成功’,MB_ICONINFORMATION);
close;
end
else
begin
application.MessageBox(’保存数据失败!’,’失败’,MB_ICONWARNING);
end;
}
end;

procedure TGetInfo.btnCloseClick(Sender: TObject);
begin
close;
end;

end.
 
看得我头疼
楼上的老兄把你的源程序发我邮箱把
我试一下
好用的话马上给分
OK??
tzlaoliu@163.com
谢谢
 
var
PostList : TStringList;
Response : TStringStream;
begin
PostList := TStringList.Create;
Response := TStringStream.Create('');
Screen.Cursor := crHourGlass;
try
with PostList do
begin
Add('SignInWelcome&siteid=223&co_partnerId=2&UsingSSL=0&ru=&pp=&pa1=&pa2=&pa3=&i1=-1&pageType=-1&userid=用户名&pass=密码'
);
end;
IdHTTP1.Post('http://signin.ebay.com.cn/ws/eBayISAPI.dll?',PostList,Response);
试试看!
 
已经发送
 
idhttp.get(http://signin.ebay.com.cn/ws/eBayISAPI.dll?SignInWelcome&siteid=223&co_partnerId=2&UsingSSL=0&ru=&pp=&pa1=&pa2=&pa3=&i1=-1&pageType=-1&userid=用户名&pass=密码)
可以得到返回的字符串,处理一下就是你要的了
 
答案基本接受,但是还是有点不懂
不过我已经试验出来了
当然也参考了上面的东西
谢谢
 

Similar threads

后退
顶部