不忘梦想,一步一步向前走。
使用pyhon脚本从一系列xml文件中提取图片的url
上一篇 /
下一篇 2011-08-02 14:16:56
/ 个人分类:测试技术
getImagefile.sh
#!/bin/env sh
#获取文件名
ls -lht *xml* > file_list_tmp
awk -F" " '{print $9}' file_list_tmp > file_list ;
----------------------------------------------------
getImageURL.py
import sys
import os
import re
cmd = "sh getimgurl.sh"
list_file=os.popen(cmd)
file_names = open("file_list",'r').readlines()
for file_name in file_names:
file_name = file_name.replace('\n','')
print "step 2"
url_file=open("url_file","w")
fp = open(file_name,"rx")
lines=fp.readlines()
fp.close()
for line in lines:
bt = '([a-zA-z]+://[^\s]*(jpg))' #url的正则表达式
m= re.search(bt,line)
if m is not None:
res = m.group()
print res
url_file.write(res+'\n')
收藏
举报
TAG: