NC222778. 登录!
描述
<input type="hidden" name="csrfmiddlewaretoken" value="xZNCrvTSCAnGTAvySpZ812J5wQKxXiOX5p0l19FRor7Hznk1P0gVyn6aArnnaQ7N">
输入描述
网页源码【样例和数据的源码均来自实际情况,只做了微调,将汉字和特殊字符用了代替,去除了网页信息】【注意,一个源码内可能有多个“关键源码”,但是关键源码的值相等】
输出描述
输出占一行,
示例1
输入:
<div class="col-xs-12"> <form class="comment_reply_form" role="form" enctype="multipart/form-data"> <input type="hidden" name="csrfmiddlewaretoken" value="xZNCrvTSCAnGTAvySpZ812J5wQKxXiOX5p0l19FRor7Hznk1P0gVyn6aArnnaQ7N"> <div data-toggle="modal" data-target="#login-modal"> <textarea class="file-comment" name="content" cols="40" rows="2" maxlength="10000" required title="##" placeholder="######...###MarkDown#Latex###"></textarea> </div> </form> <div class="col-md-offset-10 col-md-2 col-sm-offset-9 col-sm-3 col-xs-offset-7 col-xs-5"> <button class="form-control btn btn-link" style="border-radius: 5px" data-toggle="modal" data-target="#login-modal" > #### </button> </div> </div>
输出:
xZNCrvTSCAnGTAvySpZ812J5wQKxXiOX5p0l19FRor7Hznk1P0gVyn6aArnnaQ7N
示例2
输入:
<input type="hidden" name="csrfmidewaretoken" value="xZNCrvTSCAnGTAvySpZ812J5wQKxXiOX5p0l19FRor7Hk1P0gVyn6aArnnaQ7N"> <input type="hidden" name="csrfmiddlewareken" value="xZNCrvTSCAnGTAvySpZ812J5wQKxXiOX5p0l19FRor7Hznk1P0gVyn6annaQ7N"> <input type="hidden" name="csrfmiddlewaretoken" value="xZNCrvTSCAnGTAvySpZ812J5wQKxXiOX5p0l19FRor7Hznk1P0gVyn6aArnnaQ7NA"> <input type="hidden" name="csrfmiddlewareten" value="xZNCrvTSCAnGTAvySpZ812J5wQKxXiOX5p0l19FRoHznk1P0gVyn6aArnnaQ7N"> <input type="hidden" name="csriddlewaretoken" value="xZNCrvTSCAnGTAvySpZ812J5wQKxXiOX5p0l19Fr7Hznk1P0gVyn6aArnnaQ7N">
输出:
xZNCrvTSCAnGTAvySpZ812J5wQKxXiOX5p0l19FRor7Hznk1P0gVyn6aArnnaQ7NA
C++ 解法, 执行用时: 3ms, 内存消耗: 484K, 提交时间: 2021-11-25 20:47:28
#include<bits/stdc++.h> using namespace std; string t,s="name=\"csrfmiddlewaretoken\""; int main() { while(cin>>t) { if(t==s) {cin>>t;cout<<t.substr(7,t.size()-9);break;} } }
Python3 解法, 执行用时: 43ms, 内存消耗: 6900K, 提交时间: 2021-06-24 08:53:34
s=input() w="csrfmiddlewaretoken" while s.find(w)==-1: s=input() pos=s.find(w) l=s.find("value=",pos) r=s.find(">",l) ans=s[l+7:r-1] print(ans)
pypy3 解法, 执行用时: 149ms, 内存消耗: 33264K, 提交时间: 2021-06-30 21:56:50
import sys; import re; s = '' for i in sys.stdin: s += i print(re.search('name="csrfmiddlewaretoken".*?value="(.+?)"',s)[1])