1

我打开 Mozilla Firefox 插件Wappalizer并看到以下 JavaScript。这是一个正则表达式,是否可以在 python 中使用它?

    'CO2Stats':              { cats: { 1: 10 }, html: /src=("|')http:\/\/www\.co2stats\.com\/propres\.php/ },
    'CodeIgniter':           { cats: { 1: 18 }, headers: { 'Set-Cookie': /(exp_last_activity|exp_tracker|ci_session)/ }, implies: [ 'PHP' ] },
    'Commerce Server':       { cats: { 1:  6 }, headers: { 'COMMERCE-SERVER-SOFTWARE': /.+/ } },
    'comScore':              { cats: { 1: 10 }, html: /<i{1}frame[^>]* (id=("|')comscore("|')|scr=[^>]+comscore)/, env: /^_?COMSCORE$/i },
    'Concrete5':             { cats: { 1:  1 }, meta: { 'generator': /concrete5/i } },
4

1 回答 1

1

是的,//这里的字符串是正则表达式,您可以在re模块的帮助下在 python 中使用它们。

import re
if re.match('(exp_last_activity|exp_tracker|ci_session)', header_string):
  # do something

但是,当然,您需要找到必须使用此表达式分析的字符串。

于 2012-07-04T07:33:57.820 回答