一个网络下载中网址的问题。(50分)

  • 主题发起人 主题发起人 yuanzhucn
  • 开始时间 开始时间
Y

yuanzhucn

Unregistered / Unconfirmed
GUEST, unregistred user!
(在浏览器地址中输入“http://expert.csdn.net/Expert/TopicView1.asp?id=1774414”最后显示”http://expert.csdn.net/Expert/topic/1774/1774414.xml?temp=.2644464”)<br><br>在flashget中我输入网址“http://expert.csdn.net/Expert/TopicView1.asp?id=1774414”下载得到文件“1774414.xml”,它是怎么实现的。<br>我有一个程序:<br>function GetInetFile (const fileURL, FileName: String): boolean;<br>const BufferSize = 1024; <br>var <br>&nbsp; hSession, hURL: HInternet; <br>&nbsp; Buffer: array[1..BufferSize] of Byte; <br>&nbsp; BufferLen: DWORD; f: File; <br>&nbsp; sAppName: string; <br>begin <br>&nbsp; Result:=False; <br>&nbsp; sAppName := ExtractFileName(Application.ExeName); <br>&nbsp; hSession := InternetOpen(PChar(sAppName),INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); <br>&nbsp; try <br>&nbsp; &nbsp; &nbsp;hURL := InternetOpenURL(hSession, PChar(fileURL), nil,0,0,0); <br>&nbsp; &nbsp; try <br>&nbsp; &nbsp; &nbsp; &nbsp;AssignFile(f, FileName); Rewrite(f,1); <br>&nbsp; &nbsp; &nbsp; repeat <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;InternetReadFile(hURL, @Buffer, SizeOf(Buffer), BufferLen);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BlockWrite(f, Buffer, BufferLen) <br>&nbsp; &nbsp; &nbsp; until BufferLen = 0; <br>&nbsp; &nbsp; &nbsp; &nbsp;CloseFile(f); <br>&nbsp; &nbsp; &nbsp; &nbsp;Result:=True;<br><br>&nbsp; &nbsp; finally <br>&nbsp; &nbsp; &nbsp; InternetCloseHandle(hURL) <br>&nbsp; &nbsp; end <br>&nbsp; finally <br>&nbsp; &nbsp; InternetCloseHandle(hSession) <br>&nbsp; end <br>end; <br>但是当我把fileURL设为“http://expert.csdn.net/Expert/TopicView1.asp?id=1774414”时得不到我想要的1774414.xml文件,只有设为“http://expert.csdn.net/Expert/topic/1774/1774414.xml?temp=.2644464”才行。<br>
 
你不会在函数中增加一个判断功能:<br>如果id=1774414时,就把它转成'/topic/1774/1774414.xml?temp=.2644464'就可以了....
 
我给出的这个网址只是一个特例,我怎么知道其他的网址我要怎么转换,<br>你用过flashget吧,在你下载的时候,你看看他的网址是怎么变的.我就是要实现这个功能.
 
后退
顶部