msgbox

вытащить ссылки из текстовых файлов (:

May 28th, 2011
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ----------------------------------------
  2. In := "file.txt"
  3. Out := "url.html"
  4. FileRead, File, %In%
  5. StringReplace, File, File, `n, %a_space%, All
  6. Loop
  7. {
  8. if File not contains http://
  9. break
  10. else
  11. {
  12. link := RegexReplace(File, ".*http://(.*?) .*", "$1")
  13. StringReplace, File, File, http://%link%,, All
  14. link=<a href=`"http://%link%`">%link%</a><br/>
  15. exit := link exit
  16. }
  17. }
  18. FileAppend, % exit, %Out%
  19. ExitApp
  20. ; ----------------------------------------
  21. где In -- исходный файл, Out -- файл на выходе
  22.  
  23. upd.: для всех файлов в указанной папке:
  24.  
  25. ; ----------------------------------------
  26. Dir := "somedir"
  27. Out := "url.html"
  28. Loop %Dir%/*.txt
  29. {
  30. FileRead, File, %Dir%/%A_LoopFileName%
  31. StringReplace, File, File, `n, %a_space%, All
  32. Loop
  33. {
  34. if File not contains http://
  35. break
  36. else
  37. {
  38. link := RegexReplace(File, ".*http://(.*?) .*", "$1")
  39. StringReplace, File, File, http://%link%,, All
  40. link=<a href=`"http://%link%`">%link%</a><br/>
  41. exit := link exit
  42. }
  43. }
  44. }
  45. FileAppend, % exit, %Out%
  46. ExitApp
  47. ; ----------------------------------------
  48. где Dir -- папка с файлами, Out -- файл на выходе
Advertisement
Add Comment
Please, Sign In to add comment