0
對不起,如果這已被問到,但我找不到它。我試圖檢測一個網站是否使用WordPress。這裏是示例代碼。在re.search中對Python中的多個字符串使用OR運算符3
url = input("Please enter the URL")
if 'http://' in url:
append = url
else:
append = 'http://' + url
r = requests.get(append + "/robots.txt")
response = r.text
if re.search(('/wp-includes/') | ('/wp-admin/'), response):
print("{0} --> Its Wordpress ".format(append))
sys.exit(0)
它說|運營商不能使用,在
if re.search(('/wp-includes/') | ('/wp-admin/'), response):
如何搜索多個字符串,與他們之間的OR?我也嘗試過使用「或」並試用了此
if re.search('/wp-includes/' , '/wp-admin/'), response):
感謝