KageNoOni

Python, copy image urls

Mar 2nd, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. import re
  2.  
  3. inputFile=open('/path/to/file.txt', 'r')
  4. outputFile=open('/path/to/destination/file.txt', 'w')
  5.  
  6. for line in inputFile:
  7.     matches=re.findall(r'<img[^>]*src="([^"])"[^>]*>', line)
  8.     if type(matches)=str:
  9.         outputFile.write(matches)
  10.         continue
  11.     for match in matches:
  12.         outputFile.write(match)
  13.  
  14. inputFile.close()
  15. outputFile.close()
Advertisement
Add Comment
Please, Sign In to add comment