Reputation: 1594
Given a string of text which could possibly contain multiple urls all starting with http://
for example:
someString = "Text amongst words and links http://www.text.com more text more text another http http://www.word.com"
How can I extract all the urls from a string like the one above?
Leaving just
Upvotes: 0
Views: 699
Reputation: 1160
This should work:
>>> for url in re.findall('(http://\S+)', someString): print url
...
http://www.text.com
http://www.word.com
Upvotes: 1
Reputation: 2089
You want regular expressions.
In python: https://docs.python.org/2/library/re.html
Regular expression to evaluate: http://daringfireball.net/2010/07/improved_regex_for_matching_urls
Shouldn't take you long from there
Upvotes: 1