![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
九溪弥烟、
这个作者很懒,什么都没留下…
展开
-
采用requests,BeautifulSoup爬百度搜索
import requests,bs4,html5lib #导入包res=requests.get('http://www.baidu.com/s?wd=CSDN')#搜索关键字'CSDN'res.raise_for_status()res.encoding='utf8'#编码格式soup=bs4.BeautifulSoup(res.text,'html5lib')print(soup)...原创 2018-04-09 22:19:38 · 750 阅读 · 0 评论 -
Python通过网页内的文本反向找到其href链接
#write by 执笔画红颜 #红颜一笑一倾城##根据文字text 查找链接 href import requests,bs4,html5lib,re #导入包res=requests.get('http://www.baidu.com/s?wd=CSDN')#搜索关键字'CSDN'res.raise_for_status()res.encoding='utf8'#编码格式sou...原创 2018-04-09 23:01:20 · 630 阅读 · 0 评论 -
Python打开浏览器网页的方法
import webbrowserwebbrowser.open("http://www.baidu.com")原创 2018-04-11 22:53:21 · 2139 阅读 · 0 评论 -
Python编写指定路径文件的内容替换自定义的内容-正则表达式读写文件的应用
打开指定路径的文件,然后替换掉自己想要替换的内容。点击打开链接 python资料汇总#在自定义位置替换自定义文字import os,sys,pyperclip,refilename=sys.argv[1]#获取操作的文件位置print(filename)#打印文件路径信息file=open(filename,'r')#只读方式打开文件txtdata=file.read()#读取文件f...原创 2018-04-05 18:16:18 · 1787 阅读 · 1 评论 -
Python遍历指定路径下的某个文件类型,并在其查找所有符合要求的正则表达式
遍历指定路径下的某个文件类型(遍历的文件类型可自定),并在其中每个文件中查找所有符合个人要求的正则表达式点击打开链接 python资料汇总#指定目录下指定文件类型查找指定正则数据#write by 执笔画红颜import os,re,sysprint('please input the path')Searchpath=input()list=os.listdir(Searchpath...原创 2018-04-05 18:21:53 · 3205 阅读 · 0 评论 -
Python 获取文件类型后缀
import ospath='file.txt'file=os.path.splitext(path)filename,type=fileprint(filename)print(type)点击打开链接 Python资料汇总原创 2018-04-05 19:35:02 · 23200 阅读 · 0 评论