正則匹配網頁所需要的網頁內容
?這里只是記錄一下findall方法所抓取的想要的內容。
. 匹配除換行符以外的任意單個字符
* 匹配前面的子表達式零次或者是多次
? 匹配前面的子表達式零次或一次,或指明一個非貪婪限定符(匹配最近一個滿足條件的字符)
.*? 非貪婪匹配任意多個任意字符
加上re.S是全文匹配
?具體請看以下實例
import re
text = """Sxchaoinfo@EgithubE
xchaoinfo@wechat
xchaoinfo@zhihuE"""
pattern = r'S.*?E'
pattern2 = r'S.*E'
pattern3 = r'S(.*?)E'
result1 = re.findall(pattern, text)
result2 = re.findall(pattern, text, re.S)
result3 = re.findall(pattern2, text)
result4 = re.findall(pattern2, text, re.S)
result5 = re.findall(pattern3, text)
result6 = re.findall(pattern3, text, re.S)
print result1---------> ['Sxchaoinfo@E']
print result2---------> ['Sxchaoinfo@E']
print result3---------> ['Sxchaoinfo@EgithubE']
print result4---------> ['Sxchaoinfo@EgithubE\n xchaoinfo@wechat\n xchaoinfo@zhihuE']
print result5---------> ['xchaoinfo@']
print result6---------> ['xchaoinfo@']
?匹配的結果已經在代碼中貼出。
</p>[xss](javascript:alert(1))<p>