This article mainly introduces Python using regular expressions to analyze the images in the Web page and to replace the method, involving Python using regular expression techniques, with a certain reference value, the need for friends can refer to the
This example describes how Python uses regular expressions to parse pictures in a Web page and replace them. Share to everyone for your reference. The specific analysis is as follows:
This code analyzes all the picture forms in the Web page , and then adds the appropriate cosmetic labels to them before and after parsing, and adds a hyperlink to the picture.
The code is as follows: result = Value.replace ("[Page]", ""). Replace (', U ')
P=re.compile (R ' ]*?bsrc[strn]*=[strn]*[']?[ strn]* ([^strn "' <>]*") [^<>]*?/?] [strn]*>) ', Re. IGNORECASE)
result = P.sub (R ' ' <span class= "Openicon" ><em></em><a href= "2" >1</a></span> "" , result)
I hope this article will help you with your Python programming.