Autor Beitrag
Hendi48
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: Sa 01.09.07 19:07 
Hi,
ich möchte gerne mit idHTTP eine Datei auf RapidShare.com uploaden. Dazu hab ich mir folgendes gebastelt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
procedure TMainForm.RScomSendUpData;
var
  FS, FS2: TFileStream;
  s,rs2,id,s2: String;
  Data: TIdMultiPartFormDataStream;
begin
  FS:=TFileStream.Create('Temp.html',fmCreate);
  idHttp1.Get('http://rapidshare.com/',FS);
  FS.Free;
  s:=RegEx('e src=".*?"','Temp.html',True);
  Delete(s, 17);
  s:=ReverseString(s);
  Delete(s, 11);
  s:=ReverseString(s);
  FS := TFileStream.Create('temp1.html',fmCreate);
  Data := TIdMultiPartFormDataStream.Create;
  Data.AddFormField('mirror','on');
  Data.AddFormField('german','1');
  Data.AddFile('filecontent',Dateien.Strings[0],'multipart/form-data');
  idHTTP1.Post(s, Data, FS);   //sendet file
  FS.Free;
  Application.ProcessMessages;
end;

RegEx führt jeweils eine RegExpression aus und in der TStringList Dateien sind die Dateipfäde gespeichert.
Wer es testen möchte:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
procedure LoadStringFromFile(Filename: stringvar LoadString: string);
var fs:TFileStream;
begin
  fs:=TFileStream.Create(filename, fmOpenRead or fmShareDenyNone);
  SetLength(LoadString, fs.Size);
  if fs.size>0 then
    fs.Read(LoadString[1], fs.Size);
  fs.free;
end;

function TMainForm.RegEx(Mask: String; Source: String; isFile: Boolean): String;
var
  RE: TRegExpr;
  Quellcodepfad: string;
  htmlcode: string;
begin
  RE := TRegExpr.Create;
  try
    try
      if isfile then
      begin
        Quellcodepfad:=ExtractFilePath(ParamStr(0))+Source;
        LoadStringFromFile(quellcodepfad,htmlcode);
      end
      else
        htmlcode:=source;

      RE.Expression := Mask;
      if RE.Exec(htmlcode) then // die zu durchsuchende Zeichenfolge
        Result := RE.Match[0// Ergebnisausgabe
      else
        Result := 'kein Treffer';
    except
      FehlerLabel.Caption := 'Fehler: '+Exception(ExceptObject).Message
    end;
  finally
    RE.Free;
  end;
end;

Das mit dem Uploaden klappt auch, nur weiß ich nicht wie ich den Download Link dann bekommen soll. Im FS den ich über POST zurückbekomme steht nix brauchbares drin (nur diese Progressbar die beim Uploaden auf der RS.com Seite angezeigt wird). Weiß jemand wie ich den Link bekommen kann?
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: So 02.09.07 10:34 
aah Problem gelöst: Man muss hierhin uppen: "http://rapidshare.com/cgi-bin/upload.cgi" und bekommt mit post den killcode und downloadlink zurück!