필터 지우기
필터 지우기

Save a .txt file

조회 수: 2 (최근 30일)
Bob Choy
Bob Choy 2012년 12월 15일
Hey, I need help on the following:
I have a .txt file with many URLs where each line is a diferent URL. Each URL contains only a bunch of text and numbers, nothing else. How do I create a function that reads that same .txt file, accesses each one those URLs and saves to my desktop a .txt that contains the data from that URL. One .txt file per URL.
Thank you for you time.

채택된 답변

Image Analyst
Image Analyst 2012년 12월 15일
Did you check the help for fgetl()?
fid = fopen('fgetl.m');
urlString= fgetl(fid);
while ischar(urlString)
disp(urlString)
urlString = fgetl(fid);
webPageContents = urlread(urlString);
% Save it, or whatever.....
end
fclose(fid);
  댓글 수: 4
Bob Choy
Bob Choy 2012년 12월 16일
편집: Bob Choy 2012년 12월 16일
Thats EXACTLY what I needed. Thank you good sir!
Question answered.
Image Analyst
Image Analyst 2012년 12월 16일
Go ahead and mark it so.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by