HTML 긁어오는 프로그램 소스

31433 
Created at 2006-09-28 04:35:09 
173   0   0   0  
Your first task is to create a Delphi function used to download a file from the Internet. One way of achieving this task is to use the WinInet API calls. Delphi gives us full access to the WinInet API (wininet.pas) which we can use to connect to and retrieve files from any Web site that uses either Hypertext Transfer Protocol (HTTP) or File Transfer Protocol (FTP). I've already written an article that describes this technique: Get File From the Net.

Another approach, if you have Delphi 6, is to use the TDownloadURL object. The TDownloadURL object, defined in ExtActns.pas unit, is designed for saving the contents of a specified URL to a file. Here's the code that uses the TDownloadURL to download the "What's New and Hot" page from this site.


uses extactns;  // <- must be added //

function Download_HTM(const sURL, sLocalFileName:string): boolean;
begin
Result:=True;
with TDownLoadURL.Create(nil) do
try
   URL:=sURL;
   Filename:=sLocalFileName;
   try
     ExecuteTarget(nil);
   except
     Result:=False
   end;
finally
   Free;
end;
end;





This function, Download_HTM, downloads a file from the URL specified in the sURL parameter, and saves this file locally under a sLocalFileName name. The function returns True if it succeeds, False otherwise. Of course, this function is to be called from the Button1 OnClick event handler. You can see the code below. Note that, locally, the file is saved as c: emp_adp.newandhot.

procedure TForm1.Button1Click(Sender: TObject);
const
ADPNEWHOTURL='http://delphi.about.com/cs/newandhot/index.htm';
TmpFileName='c: emp_adp.newandhot';
begin
if NOT Download_HTM(ADPNEWHOTURL,TmpFileName) then
begin
   ShowMessage('Error in HTML file download');
   Exit;
end;

{
more code to be added
}

end;






Note: In the process of downloading a file, the TDownloadURL periodically generates an OnDownloadProgress event, so that you can provide users with feedback about the process. I'll leave this for you to implement.


Tags: capture grab 스크랩 윈도우즈 Share on Facebook Share on X

◀ PREVIOUS
작업관리자에 프로그램 안뜨게 하기
▶ NEXT
PHP로 객체지향 프로그래밍 하는 방법
  Comments 0
Login for comment
SIMILAR POSTS

파일에서 한줄만 읽어다 return 해주는 소스 (created at 2006-09-28)

작업관리자에 프로그램 안뜨게 하기 (created at 2006-09-28)

String Find Function (StrFnd) (created at 2006-09-28)

Toolbar에서 Icon 없애기 (created at 2006-09-28)

웹브라우져가 떠서 웹페이지 보이게 하는 소스 (created at 2006-09-28)

ActiveX에 다이얼로그 붙이기 (created at 2006-09-28)

드라이브 문자 알아내는 소스 (created at 2006-09-28)

모달리스 다이얼로그의 종료 버튼을 클릭했을 때 종료가 안될때... (created at 2006-09-28)

ActiveX에서 바이너리 데이터 파라메터로 안깨지게 받는법 (created at 2006-09-28)

ListCtrl에서 아이템 추가하기 예제 (created at 2006-09-28)

DirectShow - NULL Rendering Example (created at 2006-09-28)

Broadcast를 이용한 Application 종료 (created at 2006-09-28)

IE Control을 사용하여 만든 어플리케이션에서 javascript로 어플리케이션에 정의된 함수 호출하는 방법 (created at 2006-09-28)

윈도우 옮기는 API - SetWindowPos (created at 2006-09-28)

GDI+ Programming 방법 (created at 2006-09-28)

CFileDialog - File Open Example (created at 2006-09-28)

투명 윈도우 만들기 (created at 2006-09-28)

마우스로 윈도우 드래그하여 이동시키는 비기 (created at 2006-09-28)

불투명 윈도우 만들기 (created at 2006-09-28)

WinCE에서 Key Hooking하는 방법 (created at 2006-09-28)

비트맵을 배경으로 뿌리고 그 위에 컨트롤 올리는 방법 (created at 2006-09-28)

BITMAP 오브젝트에서 가로,세로 크기 알아내기 (created at 2006-09-28)

비트맵을 파일에서 로딩하는 비기 (created at 2006-09-28)

듀얼 모니터에서 Focused Monitor의 Rect 알아내기 (created at 2006-09-28)

프로그램에서 버젼(version) 정보 읽어주는 소스 (created at 2006-09-28)

RDP(Remote Desktop Protocol) Port 값 가져오고/바꿔주기 (created at 2006-09-28)

IE 패치에 따른 object, embed, applet 대처 방안 (created at 2006-09-28)

빈폴더 찾아내기 (created at 2006-09-29)

프로세스명으로 프로세스 죽이는 함수 (created at 2006-09-29)

자기자신 IP알아내기(로칼컴퓨터) (created at 2006-09-29)

OTHER POSTS IN THE SAME CATEGORY

wave 파일 mixing 하기. (웨이브 믹싱) (created at 2006-09-29)

ATL/ActiveX 에서 자바스크립트로 데이터(문자열) 보내기 (created at 2006-09-29)

System Log-Off, Suspend, Reboot, Shutdown 시키기 (created at 2006-09-29)

GDI+ 에서 이미지 반투명 처리하기.. (created at 2006-09-29)

자기자신 IP알아내기(로칼컴퓨터) (created at 2006-09-29)

프로세스명으로 프로세스 죽이는 함수 (created at 2006-09-29)

빈폴더 찾아내기 (created at 2006-09-29)

IE 패치에 따른 object, embed, applet 대처 방안 (created at 2006-09-28)

Virtusertable (created at 2006-09-28)

웹서버 및 웹메일 설정 방법 (created at 2006-09-28)

음력-양력 변환기 (created at 2006-09-28)

PHP에서 메일 함수가 동작하지 않을때 (created at 2006-09-28)

어떤 파라메터가 넘어왔는지 알아내는 함수 (created at 2006-09-28)

웹페이지 긁어서 타이틀 뿌려주는 소스 (created at 2006-09-28)

PHP로 객체지향 프로그래밍 하는 방법 (created at 2006-09-28)

작업관리자에 프로그램 안뜨게 하기 (created at 2006-09-28)

파일 업로드 (file upload) 사이즈 늘리기 (created at 2006-09-28)

String Find Function (StrFnd) (created at 2006-09-28)

Toolbar에서 Icon 없애기 (created at 2006-09-28)

웹브라우져가 떠서 웹페이지 보이게 하는 소스 (created at 2006-09-28)

ActiveX에 다이얼로그 붙이기 (created at 2006-09-28)

드라이브 문자 알아내는 소스 (created at 2006-09-28)

모달리스 다이얼로그의 종료 버튼을 클릭했을 때 종료가 안될때... (created at 2006-09-28)

ActiveX에서 바이너리 데이터 파라메터로 안깨지게 받는법 (created at 2006-09-28)

ListCtrl에서 아이템 추가하기 예제 (created at 2006-09-28)

DirectShow - NULL Rendering Example (created at 2006-09-28)

Broadcast를 이용한 Application 종료 (created at 2006-09-28)

IE Control을 사용하여 만든 어플리케이션에서 javascript로 어플리케이션에 정의된 함수 호출하는 방법 (created at 2006-09-28)

윈도우 옮기는 API - SetWindowPos (created at 2006-09-28)

GDI+ Programming 방법 (created at 2006-09-28)

UPDATES

글루코사민 vs. 콘드로이친: 무엇이 더 나은 관절 건강 보조제일까? (created at 2024-04-22)

광주 5·18 민주화운동 알린 테리 앤더슨 前 AP 기자 (created at 2024-04-22)

햄과 소세지가 우리 몸에 일으키는 부작용 (updated at 2024-04-22)

콘드로이친의 염증 감소효과 (updated at 2024-04-22)

코사민 DS - 글루코사민+콘드로이친 복합물이 함유된 퇴행성 관절 건강보조제 (updated at 2024-04-22)

삼겹살 먹을때 환상조합 (created at 2024-04-22)

일본 여중생의 특이한 취향 (created at 2024-04-22)

우리가 먹는 약물이 바꿔버린 생태계 (created at 2024-04-21)

일본에서 그린 상상속의 사무직과 현실속의 사무직 (updated at 2024-04-21)

북한 미대생들이 그린 북한 최고존엄 김정은 (created at 2024-04-21)

입사 후 1년도 되지 않은 회사에서 구조조정에 의한 퇴직 불응에 따른 해고 처리시 대응 가능한 방법 (updated at 2024-04-20)

한고은님의 옛날 사진 (updated at 2024-04-20)

소녀대 - Bye Bye Girl (updated at 2024-04-13)

대한민국 날씨 근황 (created at 2024-04-13)

성일종 인재육성 강조하며 이토 히로부미 언급 - 인재 키운 선례? (updated at 2024-04-13)

일제강점기가 더 살기 좋았을지도 모른다는 조수연 국민의힘 후보 - 친일파? (updated at 2024-04-13)

Marshall Ha님의 샤오미 SU7 시승기 - 테슬라의 일론 머스크님이 긴장할만한 느낌 (updated at 2024-04-09)

윙크하는 귀염둥이 반려견들 (created at 2024-04-08)

달콤 살벌한 고백 (created at 2024-04-08)

북한 최정예 공수부대 훈련 모습 (updated at 2024-04-02)

맛있었던 친구 어머니의 주먹밥이 먹고 싶어요 (created at 2024-04-02)

자리 마음에 안든다고 6급 공무원 패는 농협 조합장 (created at 2024-03-26)

85세 딸 짜장면 사주는 102세 어머니 (created at 2024-03-26)

1990년대 감각파 도둑 (created at 2024-03-26)

치매에 걸린 69살의 브루스 윌리스가 전부인 데미무어를 보고 한 말 (updated at 2024-03-22)

경제는 대통령이 살리는 것이 아닙니다 라던 윤석열대통령 - 상황 안좋아지자 여러 전략을 펼쳤지만, 부작용 속출했던 2024년의 봄 (updated at 2024-03-13)

극빈의 생활을 하고 배운것이 없는 사람은 자유가 뭔지도 모를 뿐 아니라 왜 개인에게 필요한지에 대한 필요성을 못느낀다는 윤석열 대통령 (updated at 2024-03-08)

조선일보를 안본다는 사람들이 말하는 그 이유 - 천황폐하, 전두환 각하, 김일성 장군 만세? (created at 2024-03-07)

광폭타이어를 장착하면 성능이 좋아질거라는 착각 (updated at 2024-03-03)

면허시험장에서 면허갱신하면 하루만에 끝나나? (updated at 2024-03-03)