furas

Python - search url in text using find()

Apr 13th, 2020 (edited)
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. # author: Bartlomiej "furas" Burek (https://blog.furas.pl)
  2. # 2020.04.13
  3.  
  4. text = "The link to your file is https://filecloud.com/12345/sample.png.html. If this link doesn't work, try https://filecloudlinks.com/12345/sample.png.html."
  5.  
  6. pos = 0
  7. start = text.find("https", pos)
  8. end   = text.find(".html", pos) + len(".html")
  9.  
  10. while start != -1 and end != -1:
  11.     print(text[start:end])
  12.  
  13.     pos = end
  14.     start = text.find("https", pos)
  15.     end   = text.find(".html", pos) + len(".html")
Add Comment
Please, Sign In to add comment