So cute are you Python 10
2013-10-19 16:09
281 查看
1.Python 实现抓取网页信息
2.Python 在linux 下实现根据名字,结束进程
3.实现刷博基础功能。
4.实现个人博客刷新
5.实现访问别人的博客
#!/usr/bin/evn python #coding:utf-8 #FileName:spider_01.py #Function : grasp an web page from website then show the things that you catch import urllib response = urllib.urlopen('http://blog.csdn.net/yxh1157686920') html = response.read() print html
2.Python 在linux 下实现根据名字,结束进程
#!/usr/bin/python import os,re,sys def kill_by_name(name): cmd='ps aux|grep %s'%name f=os.popen(cmd) regex=re.compile(r'\w+\s+(\d+)\s+.*') txt=f.read() if len(txt)< 5: print 'there is no thread by name or command %s'%name return ids=regex.findall(txt) cmd="kill %s"%' '.join(ids) os.system(cmd) if __name__=='__main__': if len(sys.argv)== 1: name=raw_input("type the process command name:") else: name=sys.argv[ 1] kill_by_name(name)
3.实现刷博基础功能。
#!/usr/bin/evn python #coding:utf-8 #FileName:openblog.py #Function : Open blog in loop import webbrowser import time,os,sys,re def open(): print '刷新开始。。。\r\n' for i in xrange( 0,10): webbrowser.open('http://www.baidu.com') time.sleep( 2) n='firefox' kill_by_name(n) #结束firefox进程 def kill_by_name(name): cmd='ps aux|grep %s'%name f=os.popen(cmd) regex=re.compile(r'\w+\s+(\d+)\s+.*') txt=f.read() if len(txt)< 5: print '该进程没启动或已经停止:_ %s'%name return ids=regex.findall(txt) cmd="kill %s"%' '.join(ids) os.system(cmd) if __name__=='__main__': open() web='http://www.126.com' #splinter(web)
4.实现个人博客刷新
#!/usr/bin/evn python #coding:utf-8 #FileName:openblog.py #Function : Open blog in loop import webbrowser import time,os,sys,re def open(): print '刷新开始。。。\r\n' #web=raw_input('请输入博客网址:_(example:http://www.yahoo.com/)\r\n:_') #if web=='': web='http://home.51cto.com/index.php?s=/space/7743046' for i in xrange(0,10): webbrowser.open(web) time.sleep(2) n='firefox' kill_by_name(n) #结束firefox进程 def kill_by_name(name): cmd='ps aux|grep %s'%name f=os.popen(cmd) regex=re.compile(r'\w+\s+(\d+)\s+.*') txt=f.read() if len(txt)<5: print '该进程没启动或已经停止:_ %s'%name return ids=regex.findall(txt) cmd="kill %s"%' '.join(ids) os.system(cmd) if __name__=='__main__': while True: open()
5.实现访问别人的博客
#!/usr/bin/evn python #coding:utf-8 #FileName:openblog.py #Function : Open blog in loop import webbrowser import time,os,sys,re def open(num): print '刷新开始。。。\r\n' #web=raw_input('请输入博客网址:_(example:http://www.yahoo.com/)\r\n:_') #if web=='': web='http://home.51cto.com/index.php?s=/space/00'+str(num) for i in xrange(0,2): webbrowser.open(web) time.sleep(10) n='firefox' kill_by_name(n) #结束firefox进程 def kill_by_name(name): cmd='ps aux|grep %s'%name f=os.popen(cmd) regex=re.compile(r'\w+\s+(\d+)\s+.*') txt=f.read() if len(txt)<5: print '该进程没启动或已经停止:_ %s'%name return ids=regex.findall(txt) cmd="kill %s"%' '.join(ids) os.system(cmd) if __name__=='__main__': global num num=850 while True: open(num) num+=1 print num
相关文章推荐
- So cute are you python 4
- So cute are you Python 13
- So cute are you Python 9
- So cute are you Python 11
- So cute are you Python 12
- So cute are you python 16
- So cute are you python 15
- So cute are you python 6
- so cute are you python 18
- So cute are you python 2
- So cute are you python 3
- So cute are you python 7
- So cute are you python 14
- So cute are you python 17
- So cute are you python 5
- So cute are you python 1
- Python!Are you kidding me?
- 错误 You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work
- 异常:This application has no explicit mapping for /error, so you are seeing this as a fallback.
- 就这样被你感动(We Are So Moved By You)