从 HTTP 链接提取 ZIP 文件我已经发布了 ZIP 文件,并希望以编程方式提取它们并使用 JSL 存储到我的 PC 上。 我事先不知道会有多少文件。
JSL 可以做到这一点吗?

回复:从 HTTP 链接提取 ZIP 文件很高兴你能从中得到一些东西! 我很确定该模式可以在速度方面得到改进。 对于只有几千个链接的目录来说可能没有什么区别,但 len(1) 部分可以更快地跳过非链接文本。 更灵活的链接模式也会更好。
@bryan_boone @欧内斯特帕索尔@paul_vezzetti
回复:从 HTTP 链接提取 ZIP 文件感谢克雷格的全面答复。 我将采纳这两个建议的元素,并将其合并到一个通用函数中,以满足我当前和未来的需求。
我知道我必须使用 REGEXP 来查找来自 HTTP 源的链接,但希望 zip 部分有一个 '<< saveLink' 函数。 
不过这会工作得很好。
很好的答案
回复:从 HTTP 链接提取 ZIP 文件或者这可能更接近您的要求:
path="https://www.vsp.virginia.gov/downloads/"; // a page with an index of files. Yours may be different format, adjust pattern below.
html = loadtextfile(path); // get the HTML text so we can scrape the links
// somewhat custom pattern for scraping the links, may be specific to this page
urls = {}; // this list will collect the urls
rc = patmatch(html,
patpos(0)+ // make sure the pattern matches from the start
patrepeat( // this is the loop that extracts the urls from the html
(
// the urls look like <A href="https://community.jmp.com/2017%20Virginia%20Firearms%20Dealers%20Procedrures%20Manual.pdf" target="_blank" rel="nofollow noopener noreferrer">
// and we want just the part between the quotation marks. Quickly scan forward (patBreak)
// for a < then see if it matches. >>url grabs the text between quotation marks.
(patbreak("<") + "</A><A href="\!""" target="_blank" rel="nofollow noopener noreferrer">> url + pattest(insertinto(urls,url);1))
| // OR
patlen(1) // skip forward one character
)
+
patfence() // fence off the successfully matched text. There is no need to backtrack if something goes wrong.
) +
patrepeat(patnotany("<"),0) + // any trailing bits of html are consumed here
patrpos(0) // make sure the pattern matches to the end
);
if(rc==0, throw("pattern did not match everything"));
show(nitems(urls),urls[6]); // pick item 6. You'll have a different strategy.
fullpath = path||regex(urls[6],"%20"," ",GLOBALREPLACE);// minimal effort to fix up the url, might need more work
pdfblob = loadtextfile(fullpath,blob); // download item 6, it is a pdf when this was written...
savetextfile("$temp/example.pdf",pdfblob); // save it somewhere</A>回复:从 HTTP 链接提取 ZIP 文件
zip 文件来自@威尔卡普推介会
za=open("https://community.jmp.com/kvoqx44227/attachments/kvoqx44227/virtual-jug/12/1/VJUG%20July%202015.zip","zip");
zipfiles=za<
有几点需要注意
- 文件被下载到您的临时目录;打开的“zip”选项返回一个 zip 存档对象
- 您可以使用 <
- 您可以使用带有 zip 存档的 blob 格式来读取 JMP 表等二进制数据
- 第三行使用第二个参数告诉 open 该 blob 是 JMP 数据表
- 如果重新运行整个脚本,则需要清除 za 变量; zip 存档对象可防止临时目录中的文件被重复使用。
- 您可以使用 loadtextfile/savetextfile 和 blob 将 zip 文件下载到您选择的位置(完成后将其删除),然后使用 zip 存档来处理该文件。
- 我已经看到存档目录中的第四项是 JMP 数据表