--很简单的功能, 知道URL, 通过HTTP批量下载
--附带希尔顿图60张url
--把以下内容存放到d:/temp/xxx3.txt中即可
63483cb9nvb19xxnmn691 63483cb9nvb19xxnq3gma 63483cb9nvb19xxnr89db 63483cb9nvb19xxnsw826 63483cb9nvb19xxnukbug 63483cb9nvb19xxnwy4cx 63483cb9nvb19xxnxw904 63483cb9nvb19xxo1la1v 63483cb9nvb19xxo2ll4a 63483cb9nvb19xxo7awgd 63483cb9nvb19xxo8dkx9 63483cb9nvb19xxoa1ll3 63483cb9nvb19xxobpkfa 63483cb9nvb19xxocs713 63483cb9nvb19xxoeotks 63483cb9nvb19xxogaj6s 63483cb9nvb19xxoijzuy 63483cb9nvb19xxol8fkc 63483cb9nvb19xxomjmha 63483cb9nvb19xxooihnc 63483cb9nvb19xxos9d7g 63483cb9nvb19xxowq7nj 63483cb9nvb19xxoyzk8d 63483cb9nvb19xxp0cuxp 63483cb9nvb19xxp2bleu 63483cb9nvb19xxp3ih9f 63483cb9nvb19xxp5u6g5 63483cb9nvb19xxp83hwr 63483cb9nvb19xxp9vu4d 63483cb9nvb19xxpb2ni4 63483cb9nvb19xxpdgea2 63483cb9nvb19xxpfptua 63483cb9nvb19xxpguk7l 63483cb9nvb19xxpimxm8 63483cb9nvb19xxpjrnca 63483cb9nvb19xxplsix4 63483cb9nvb19xxpotws9 63483cb9nvb19xxpq520t 63483cb9nvb19xxpud6qr 63483cb9nvb19xxpvwt6h 63483cb9nvb19xxpy1zm7 63483cb9nvb19xxq67rdt 63483cb9nvb19xxq7zyes 63483cb9nvb19xxqdf4bd 63483cb9nvb19xxqfx1ue 63483cb9nvb19xxqi0157 63483cb9nvb19xxqjyqws 63483cb9nvb19xxqlxhz8 63483cb9nvb19xxrjotaw 63483cb9nvb19xxrmb638 63483cb9nvb19xxrnk7pc 63483cb9nvb19xxrpa8od 63483cb9nvb19xxrr2lth 63483cb9nvb19xxrtt44j 63483cb9nvb19xxrw9470 63483cb9nvb19xxry5m78 63483cb9nvb19xxs0jcv6 63483cb9nvb19xxs1wm5k 63483cb9nvb19xxs3krgs 63483cb9nvb19xxs6yvkq require "wx" print_lua("> using wxHTTP get picture/n"); local addr = wx.wxIPV4address(); addr:Hostname("static2.photo.sina.com.cn"); addr:Service(80); function http_download(url, file) local get = wx.wxHTTP(); get:SetHeader("content-type", "text/html"); get:SetTimeout(3); print_lua("> connect " .. addr:IPAddress()); while(not get:Connect(addr))do wx.wxSleep(5) end; local is = get:GetInputStream(url); if (is) then print_lua(">> save to " .. file); local ofs = wx.wxFileOutputStream(file); is:Read(ofs); else print_lua(">> not found " .. url); end end for line in io.lines("d://temp//xxx3.txt", "r") do http_download("/orignal/" .. line, "d://temp//xed//" .. line .. ".jpg"); end
现在有许多图片浏览都在html中使用了这样的代码
<dt>巴尔-莱法利性感内衣秀</dt> <dd>http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53075_276517.jpg</dd> <dd>http://www.sinaimg.cn/dy/slidenews/3_t160/2011_04/17496_53075_276517.jpg</dd> <dd>http://www.sinaimg.cn/dy/slidenews/3_t50/2011_04/17496_53075_276517.jpg</dd> <dd>2011年01月30日 10:31</dd> <dd>近日,莱昂纳多女友巴尔-莱法利(Bar Refaeli)的一组性感内衣写真曝光。<br /></dd> <dd><a href="http://comment4.news.sina.com.cn/comment/skin/default.html?channel=shuo&newsid=slidenews-17496-53075" mce_href="http://comment4.news.sina.com.cn/comment/skin /default.html?channel=shuo&newsid=slidenews-17496-53075">评论< /a></dd> <dd>53075</dd> </dl> <dl> <dt>巴尔-莱法利性感内衣秀</dt> <dd>http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53076_388879.jpg</dd> <dd>http://www.sinaimg.cn/dy/slidenews/3_t160/2011_04/17496_53076_388879.jpg</dd> <dd>http://www.sinaimg.cn/dy/slidenews/3_t50/2011_04/17496_53076_388879.jpg</dd> <dd>2011年01月30日 10:31</dd> <dd>近日,莱昂纳多女友巴尔-莱法利(Bar Refaeli)的一组性感内衣写真曝光。<br /></dd> <dd><a href="http://comment4.news.sina.com.cn/comment/skin/default.html?channel=shuo&newsid=slidenews-17496-53076" mce_href="http://comment4.news.sina.com.cn/comment/skin /default.html?channel=shuo&newsid=slidenews-17496-53076">评论< /a></dd> <dd>53076</dd> </dl> 用LUA的pattern就很容易把它们的URL提取出来放在文件中. ifile = io.open("d://temp//xxx-2.html", "r"); ofile = io.open("d://temp//xxx-2.txt", "w"); s = ifile:read("*a"); -- read html file to string s -- using pattern fetch url string.gsub(s, "</dt>/n%s*<dd>(.-)</dd>/n", function(ns) ofile:write(ns .. "/n"); end ) io.close(ofile); io.close(ifile); 如http://slide.eladies.sina.com.cn/news/slide_3_17496_5277.html#p=1 提取得url http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53070_929205.jpg http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53071_366290.jpg http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53072_799320.jpg http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53073_764916.jpg http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53074_520663.jpg http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53075_276517.jpg http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53076_388879.jpg http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53077_345870.jpg http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53078_741082.jpg http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53079_772506.jpg http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53080_214160.jpg http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53081_909902.jpg http://www.sinaimg.cn/dy/slidenews/3_img/2011_04/17496_53082_799409.jpg