摘要: 协程基本语法import asyncioasync def request(url): print('正在请求的url是',url) print('请求成功',url) return url# ... 阅读全文
posted @ 2020-08-20 16:38 消磨_时间 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 线程池基本语法import timefrom multiprocessing.dummy import Poolstart_time = time.time()def get_page(str): prin... 阅读全文
posted @ 2020-08-20 16:33 消磨_时间 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 线程池方式 import requestsfrom lxml import etreefrom bs4 import BeautifulSoupfrom lxml.html import tostringimpo... 阅读全文
posted @ 2020-08-16 20:11 消磨_时间 阅读(791) 评论(0) 推荐(0) 编辑
摘要: 线程池方式import requestsfrom lxml import etreefrom bs4 import BeautifulSoupimport timeimport osfrom multiproce... 阅读全文
posted @ 2020-08-15 21:55 消磨_时间 阅读(473) 评论(0) 推荐(0) 编辑
摘要: bs4方式import requestsfrom lxml import etreefrom bs4 import BeautifulSoupimport timeimport osheaders = { ... 阅读全文
posted @ 2020-08-15 17:15 消磨_时间 阅读(634) 评论(0) 推荐(0) 编辑
摘要: 爬取城市列表# -*- coding:utf-8 -*-import requestsfrom lxml import etreeimport osif __name__ == "__main__": # ... 阅读全文
posted @ 2020-08-14 13:07 消磨_时间 阅读(123) 评论(0) 推荐(0) 编辑
摘要: requests模块: - 安装 pip install requests - 定义url url = 'https://www.sougou.com/' - UA伪... 阅读全文
posted @ 2020-08-14 12:35 消磨_时间 阅读(61) 评论(0) 推荐(0) 编辑
摘要: xpath解析: -最常用且最高效便捷的一种解析方式,通用性强. - xpath解析原理 - 1. 实例化一个etree的对象,且需要将被解析的页面源码数据加载到该对象中 ... 阅读全文
posted @ 2020-08-14 12:22 消磨_时间 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 抓取三国演义小说# -*- coding:utf-8 -*-import requestsfrom bs4 import BeautifulSoupimport lxmlif __name__ == "__mai... 阅读全文
posted @ 2020-08-14 10:32 消磨_时间 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 1. 基础import requestsif __name__ == "__main__": # 1. 指定url url = 'https://www.sougou.com/' headers... 阅读全文
posted @ 2020-08-13 15:03 消磨_时间 阅读(211) 评论(0) 推荐(0) 编辑