How to write Python regular expression to get all the anchor tags in a webpage?

PythonServer Side ProgrammingProgramming

The following code extracts all tags in the given string

Example

import re
rex = re.compile(r'[\<\>]')
l = "this is text1 <a href='irawati.com' target='_blank'>hi</a> this is text2"
print rex.findall(l)

Output

['<', '>', '<', '>']
raja
Published on 11-Jan-2018 12:58:37
Advertisements