首页
文章
分类
标签
更多
时光机
友情链接
Search
1
史上超全共享单车车锁的开锁方式(含具体方案)转
5,193 阅读
2
渗透测试工具实战技巧合集
3,490 阅读
3
URP综合教务系统通杀getshell
3,019 阅读
4
pentestbox 下安装whatweb后,报IPADDR模块没有配置的解决办法。
2,861 阅读
5
Pentest BOX安装和使用
2,306 阅读
学习资料
工具
视频
笔记
登录
Search
标签搜索
python
javascript
pentestbox
NSA
cms
linux
前端知识
jquery
安全
mysql
php
seafile
seahub
wdcp
Richar
累计撰写
130
篇文章
累计收到
4
条评论
首页
栏目
学习资料
工具
视频
笔记
页面
文章
分类
标签
时光机
友情链接
搜索到
2
篇与
python
的结果
2017-06-17
用Python写的一个简单的猜数字游戏
刚入门,代码较渣,轻喷# _*_ coding:utf-8 _*_ import random guess=random.randrange(1,100) #随机生成一个100以内的数 print '**********猜数游戏,随机生成100以内的数***********' trys=input('请输入你想要挑战的次数:\n') #自定义挑战次数 id=1 while id<=int(trys): txt=input('请输入你的第%s次猜数:\n'%id) if txt=='stop': break else: answer=int(txt) if answer<guess: print('你猜的数太小了\n') elif answer>guess: print('你猜的数太大了\n') else: print('恭喜你,猜对了\n') exit() id+=1 print '很遗憾,你所有的机会都用完了,正确的答案是%s下次加油吧!\n'%guess
2017年06月17日
1,480 阅读
0 评论
0 点赞
2017-06-13
用PYTHON写的第一个爬虫程序,并以EXCEL格式保存
自己动手写的第一个Python爬虫,代码比较渣,大神略过。# _*_ coding:utf-8 _*_ import requests,xlwt,json,time,random items=[] def get_content(pn): url='https://www.lagou.com/jobs/positionAjax.json?needAddtionalResult=false' #提交的URL data={'first':'true', #带参数提交 'pn':pn, 'kd':'python'} html=requests.post(url,data).text #获取网页内容 html=json.loads(html) #转成JSON格式 for i in range(14): item=[] item.append(html['content']['positionResult']['result'][i]['positionName']) #职位名称 item.append(html['content']['positionResult']['result'][i]['salary']) #薪资 item.append(html['content']['positionResult']['result'][i]['companyFullName']) #公司名称 item.append(html['content']['positionResult']['result'][i]['workYear']) #要求 # print u'职位名称:%s 薪资:%s 公司名: %s 要求: %s'%item[0],%item[1],%item[2],%item[3] print u'职位名称:%s\n'u'工资:%s\n' u'公司名称:%s\n'u'要求:%s\n'%(item[0],item[1],item[2],item[3]) items.append(item) return items def excel_write(): newtable='test.xls'#excel表名 wb=xlwt.Workbook(encoding='utf-8') #创建并设置表 ws=wb.add_sheet('text1') #创建表的名称 headData=['职位名称','薪资','公司名称','要求'] #设置EXCEL表头 for hd in range(0,4): ws.write(0,hd,headData[hd],xlwt.easyxf('font:bold on ')) #第0行0例开始写入表头 id=1 index=1 while id<=4: get_content(id) id+=1 time.sleep(random.randrange(0,3))#随机休眠几秒防IP锁定 for item in items: #从列表数组里取一行 for i in range(0,4): #从item里取出每列的值 ws.write(index,i,item[i]) index+=1 wb.save(newtable)#保存并生成EXCEL if __name__=="__main__": excel_write() print u'*****************共爬取并写入EXCEL数据%s条************'%len(items)
2017年06月13日
1,436 阅读
0 评论
0 点赞