Reading urls only from a text file

2 次查看(过去 30 天)
ab
ab 2013-7-1
I have a text file having multiple urls with other information of the url.I want to download images from all the urls. How can I read the txt file and save the URLS only in an array to download it? I want to use C=textscan(fileId,formatspec) What should I mention in formatspec for URL as format? My text file has the content shown as below:
ID: 262
Name: VD0289 CUT OUT BACK DRESS
Image: http://dwimages.com/images/product/1/VD0289_VD0289_(4).jpg
Detailed Image: http://dwimages.com/images/detailed/0/VD0289_VD0289_(4).jpg
Image: http://dwimages.com/images/product/1/
Detailed Image: http://dwimages.com/images/detailed/1/VD0289_VD0289_(4).jpg
Detailed Image: http://dwimages.com/images/detailed/0/VD0289_VD0289.jpg
  2 个评论
Matt Kindig
Matt Kindig 2013-7-1
I would use regular expressions instead of textscan(). Something like this should do it:
str= fileread('/path/to/your/file.txt'); %read in text file to memory
urls = regexp(str, 'http(\S+)(\s*)$', 'match', 'lineAnchors'); %find urls
ab
ab 2013-7-1
编辑:ab 2013-7-1
Thanks it worked :).How can I assign the Name:VD0289 CUT OUT BACK DRESS to all the images under it in a lookup table.I have a lot of datas in this same format in the same txt file.Eg
I have this datas how can I make a lookup table to assign each url with its name and tags.that is the first 5 image should have the same name and tags assigned.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Large Files and Big Data 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by