我有一个文本文档,我想从中提取URL并将其放置在新的文本文件中。如何在Perl中做到这一点?文本文件的示例在这里:


{“ type”:“ TabGroupsManager:GroupData”,“ id”:65,“ name”:“ XML
架构图
编辑器”,“图片”:“ http://www.altova.com/favicon.ico”,“ disableAutoRename”:false,“ titleList”:“ XML”
架构编辑器\ u000aAltova XMLSpy代码
一代\ u000a在线视频
演示\ u000a预定的数据交换
案例研究\ u000aXML编辑器\ u000aAltova
XMLSpy 2011 \ u000aXML模式管理
工具\ u000a“,”标签“:[” {\“条目\”:[{\“ URL \”:\“ http://www.altova.com/xmlspy/xml-schema-editor.html \”, \“标题\”:\“ XML
架构图
编辑者\“,\” ID \“:1442422751,\”引荐网址\“:\” http://www.altova.com/xmlspy/xml-editing.html \“,\”滚动\“:\” 0, 0 \“,\” formdata \“:{\”#q \“:\” \“}}],\” index \“:1,\” attributes \“:{\” image \“:\” http ://www.altova.com/favicon.ico \“},\” extData \“:{\” TabGroupsManagerGroupId \“:\” 65 \“,\” TabGroupsManagerGroupName \“:\\ XML
架构图
编辑器\“},\” _formDataSaved \“:true}”,“ {\” entrys \“:[{\” url \“:\” http://www.altova.com/xmlspy/xml-code-generation .html \“,\” title \“:\” Altova
XMLSpy代码
Generation \“,\” ID \“:1442423118,\” referrer \“:\” http://www.google.com/search?hl=zh_CN&client=firefox-a&hs=GR1&rls=org.mozilla%3Aen-GB% 3Aofficial&q = altova + derive + schema + from + xml&aq = f&aqi = m1&aql =&oq =&gs_rfai = \“,\” scroll \“:\” 0,0 \“,\” formdata \“:{\”#q \“ :\“ \”}}],\“索引\”:1,\“属性\”:{\“图像\”:\“ http://www.altova.com/favicon.ico \”}},\ “ extData \”:{\“ TabGroupsManagerGroupId \”:\“ 65 \”,\“ TabGroupsManagerGroupName \”:\\ XML
架构图
编辑器\“},\” _formDataSaved \“:true}”,“ {\” entrys \“:[{\” url \“:\” http://www.altova.com/videos.asp?type=0&video = xmlspy \“,\”标题\“:\”在线
视频
Demos \“,\” ID \“:1442423184,\” referrer \“:\” http://www.altova.com/xmlspy/xml-code-generation.html \“,\” scroll \“:\” 0,0 \“,\” formdata \“:{\”#q \“:\” \“}}}],\”索引\“:1,\”属性\“:{\”图像\“:\ “ http://www.altova.com/favicon.ico\"},\"extData\":{\"TabGroupsManagerGroupId\":\"65\",\"TabGroupsManagerGroupName\":\\XML
架构图
编辑器\“},\” _formDataSaved \“:true}”,“ {\” entrys \“:[{\” url \“:\” http://www.altova.com/solutions/exchange_ratecasestudy.html \“ ,\“标题\”:\“预定
数据交换案例
Study \“,\” ID \“:2618,\” formdata \“:{\”#q \“:\” \“},\” scroll \“:\” 0,1369 \“}],\” index \“:1,\” attributes \“:{\” image \“:\” http://www.altova.com/favicon.ico \“},\” extData \“:{\” TabGroupsManagerGroupId \“ :\“ 65 \”,\“ TabGroupsManagerGroupName \”:\“ XML
架构图
编辑器\“},\” _ formDataSaved \“:true}”,“ {\”条目\“:[{\” url \“:\” http://www.altova.com/xml-editor/ \“, \“标题\”:\“ XML
编辑者\“,\” ID \“:2620,\” formdata \“:{\”#q \“:\” \“},\”滚动\“:\” 0,0 \“}],\” index \“:1,\” attributes \“:{\” image \“:\” http://www.altova.com/favicon.ico \“},\” extData \“:{\” TabGroupsManagerGroupId \“ :\“ 65 \”,\“ TabGroupsManagerGroupName \”:\“ XML
架构图
编辑器\“},\” _formDataSaved \“:true}”,“ {\” entrys \“:[{\” url \“:\” http://manual.altova.com/XMLSpy/spystandard/index.html ?xmlschemasstd.htm \“,\”标题\“:\” Altova
XML间谍
2011 \“,\” ID \“:2622,\”儿童\“:[{\” url \“:\” http://manual.altova.com/XMLSpy/spystandard/xmlspy_content_dyn.html \“,\” title \“:\” Altova XMLSpy
2011 \“,\” ID \“:2623,\” referrer \“:\” http://manual.altova.com/XMLSpy/spystandard/index.html?xmlschemasstd.htm \“,\” scroll \“: \“ 0,0 \”},{\“ url \”:\“ http://manual.altova.com/XMLSpy/spystandard/xmlschemasstd.htm \”,\“标题\”:\“ XML
模式\“,\” ID \“:2624,\”引荐网址\“:\” http://manual.altova.com/XMLSpy/spystandard/index.html?xmlschemasstd.htm \“,\”滚动\“: \“ 0,260 \”}],\“ scroll \”:\“ 0,0 \”}],\“ index \”:1,\“ attributes \”:{},\“ extData \”:{\“ TabGroupsManagerGroupId \“:\” 65 \“,\” TabGroupsManagerGroupName \“:\” XML
架构图
编辑器\“},\” _ formDataSaved \“:true}”,“ {\”条目\“:[{\” URL \“:\” http://www.altova.com/schemaagent.html \“,\ “ title \”:\“ XML
模式管理
工具\“,\” ID \“:2626,\” formdata \“:{\”#q \“:\” \“},\”滚动\“:\” 0,171 \“}},\”索引\ “:1,\”属性\“:{\”图片\“:\” http://www.altova.com/favicon.ico \“}} \\” extData \“:{\” TabGroupsManagerGroupId \“:\\ “ 65 \”,\“ TabGroupsManagerGroupName \”:\“ XML
架构图
编辑器\“},\” _ formDataSaved \“:true}”]}


从那我想创建一个文本文件,如:

http://www.altova.com/xmlspy/xml-schema-editor.html
http://www.altova.com/xmlspy/xml-code-generation.html

最佳答案

由于该文件似乎是JSON文件而不是纯文本文件,因此请使用JSON modules on CPAN之一。由于您似乎已经将数据编码为JSON,然后以字符串形式存储在更大的对象中,然后又将其转换为JSON,因此这有点复杂,因此您将必须解析文件,提取字符串并将其解析为JSON。打开然后从中提取URI。

关于perl - 如何从JSON数据提取URL?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3899719/

10-10 19:04