![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python学习
WAIT_TIME
这个作者很懒,什么都没留下…
展开
-
爬虫基础-协程基本语法
协程基本语法import asyncioasync def request(url): print('正在请求的url是',url) print('请求成功',url) return url# async修饰的函数, 调用之后返回一个协程对象c = request('www.baidu.com')# 创建一个事件循环对象loop = asyncio.get_event_loop()# 将协程对象注册到loop中,然后启动looploop.run_until_c原创 2020-08-20 16:38:18 · 206 阅读 · 0 评论 -
爬虫基础-爬取某神坛图片
import requestsfrom lxml import etreefrom bs4 import BeautifulSoupfrom lxml.html import tostringimport timeimport osimport reif __name__ == "__main__": page_url = 'https://cl.fs55.xyz/thread0806.php?fid=16&page=%d' server = 'https://cl..原创 2020-08-16 20:11:14 · 6905 阅读 · 0 评论 -
爬虫基础-爬取某神坛小说
import requestsfrom lxml import etreefrom bs4 import BeautifulSoupimport timeimport osif __name__ == "__main__": if not os.path.exists('./download/CL_Ebook'): os.makedirs('./download/CL_Ebook') headers = { 'User-Agent': 'Mozil.原创 2020-08-15 21:55:09 · 1097 阅读 · 0 评论 -
爬虫基础-bs4方式和xpath方式提取标签下所有文本
bs4方式url = 'http://www.bequgew.com/51561/18969923.html'response = requests.get(url=url,headers=headers)response.encoding = 'gbk'# bs4方式soup = BeautifulSoup(response.text, 'lxml')content = soup.find('div', id='book_text').textxpath方式url = '..原创 2020-08-15 17:15:07 · 1146 阅读 · 0 评论 -
爬虫基础-xpath解析样例
爬取58二手房title# -*- coding:utf-8 -*-import requestsfrom lxml import etreeif __name__ == "__main__": # 获取页面数据 headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Sa原创 2020-08-14 13:06:40 · 315 阅读 · 0 评论 -
爬虫基础-requests模块基础
requests模块: - 安装 pip install requests - 定义url url = 'https://www.sougou.com/' - UA伪装 headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Sa.原创 2020-08-14 12:34:57 · 156 阅读 · 0 评论 -
爬虫基础-xpath数据解析基础
xpath解析: -最常用且最高效便捷的一种解析方式,通用性强. - xpath解析原理 - 1. 实例化一个etree的对象,且需要将被解析的页面源码数据加载到该对象中 - 2. 调用etree对象中的xpath方法结合着xpath表达式实现标签的定位和内容的捕获. - 环境安装: - pip install lxml - 如何实例化一个etree对象 - 1. 将本地的html文档中的源码数据加载到etre.原创 2020-08-14 12:22:26 · 168 阅读 · 0 评论 -
爬虫基础-bs4数据解析样例
抓取三国演义小说# -*- coding:utf-8 -*-import requestsfrom bs4 import BeautifulSoupimport lxmlif __name__ == "__main__": headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 S原创 2020-08-14 10:31:50 · 349 阅读 · 0 评论 -
爬虫基础-requests模块使用样例
1. 基础import requestsif __name__ == "__main__": # 1. 指定url url = 'https://www.sougou.com/' headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36'原创 2020-08-13 15:03:04 · 624 阅读 · 0 评论 -
爬虫基础-bs4数据解析基础
bs4进行数据解析 - 数据解析原理 - 1. 标签定位 - 2. 提取标签, 标签属性中存储的数据值 - bs4数据解析原理 - 1. 实例化一个BeautifulSoup对象,并且将页面源码加载到该对象中 - 2. 通过调用BeautifulSoup对象中相关的属性或者方法进行标签定位或者数据提取 - 环境安装 pip install bs4 pip install lxml.原创 2020-08-13 14:57:34 · 471 阅读 · 0 评论 -
Sublime Texe3编写python代码
1.安装python2.安装Sublime Texe3支持python运行打开软件-->Preferences-->Browes packages...新建Python-->在Python中新建Python.sublime-commands编辑Python.sublime-commands路径根据实际情况来{"cmd":["python.exe", "-u", "$file"],...原创 2018-04-10 14:56:52 · 288 阅读 · 0 评论 -
pycharm-professional2018激活
1.修改hosts0.0.0.0 account.jetbrains.com 2.激活激活码: SSUJFAQGMI-eyJsaWNlbnNlSWQiOiJTU1VKRkFRR01JIiwibGljZW5zZWVOYW1lIjoiWmhpd2VpIEhvbmciLCJhc3NpZ25lZU5hbWUiOiIiLCJhc3NpZ25lZUVtYWlsIjoiIiwibGljZW5zZV...原创 2018-04-17 11:01:57 · 1152 阅读 · 0 评论 -
Centos6.5安装python3
下载#wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz -P /usr/local/src/编译安装#cd src#tar -zxf Python-3.6.4.tgz#cd Python-3.6.4#./configure --prefix=/usr/local/Python-3.6.4#make && ma...原创 2018-03-10 09:55:04 · 508 阅读 · 0 评论 -
使用pyinstaller将python文件打包成exe
例如d:\install\get_type.py文件打包成exe执行文件1.安装pyinstaller(首先安装pip)进入到D:\Program Files\Python36\Scriptspip install pyinstaller或者pip3 install pyinstaller安装后进入到D:\Program Files\Python36\Scriptspyinstaller.exe ...原创 2018-05-04 15:22:29 · 113 阅读 · 0 评论