题目地址:http://sec.hdu.edu.cn/question/web/1076/
这一题跟上一篇那题有点相似,查看一下源代码:
发现字符产所处的HTML标签变了,还有就是上一题是get请求,而这一题是post请求。
那就修改下python代码,如下:
# coding=UTF-8 import requestsfrom bs4 import BeautifulSoupurl = "http://sec.hdu.edu.cn/question/web/1076/"q = requests.session()webcontext = q.get(url).text #获取页面内容content=webcontext.split('
')a=content[1]Unicode2str=a.encode("utf-8")ln=len(a)s=0e=0c=0l=0a=0b=0for i in range(ln): if (Unicode2str[i] == 's' ): s=s+1 elif (Unicode2str[i]== 'e' ): e=e+1 elif (Unicode2str[i] == 'c' ): c=c+1 elif (Unicode2str[i]== 'l' ): l=l+1 elif (Unicode2str[i] == 'a' ): a=a+1 elif (Unicode2str[i]=='b'): b=b+1 else: continuevalue='%d' %s +'%d' %e +'%d' %c +'%d' %l +'%d' %a +'%d' %bgetdata={ 'answer':value}result=q.post(url,data=getdata)z=result.textx=z.encode('GBK','ignore')print x
运行得到flag。