标签:
题目地址:http://sec.hdu.edu.cn/question/web/1076/
这一题跟上一篇那题有点相似,查看一下源代码:
发现字符产所处的HTML标签变了,还有就是上一题是get请求,而这一题是post请求。
那就修改下python代码,如下:
# coding=UTF-8 import requests from bs4 import BeautifulSoup url = "http://sec.hdu.edu.cn/question/web/1076/" q = requests.session() webcontext = q.get(url).text #获取页面内容 content=webcontext.split(‘<hr/>‘) a=content[1] Unicode2str=a.encode("utf-8") ln=len(a) s=0 e=0 c=0 l=0 a=0 b=0 for 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: continue value=‘%d‘ %s +‘%d‘ %e +‘%d‘ %c +‘%d‘ %l +‘%d‘ %a +‘%d‘ %b getdata={‘answer‘:value} result=q.post(url,data=getdata) z=result.text x=z.encode(‘GBK‘,‘ignore‘) print x
运行得到flag。
标签:
原文地址:http://www.cnblogs.com/lovealways/p/5861634.html