![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python爬虫
小吴今天运动了吗
满怀希望就能所向披靡
展开
-
Scrapy框架(三)
Spider的使用 爬取百度文库原创 2021-08-02 15:07:44 · 193 阅读 · 0 评论 -
Scrapy框架(二)
Selector选择器 基于lxml构建出来。 1.使用 直接导入模块,然后实例化使用。Selector支持css,re,xpath等解析方式 from scrapy import Selector content = "<html><head><title>My html</title><body><h3>Hello world!</h3></body></head></html&原创 2021-07-22 10:32:35 · 96 阅读 · 0 评论 -
Scrapy框架(一)
一、架构图 是专门为python爬虫设计的框架。定制解析模块就能实现爬虫。 Scrapy Engine: 安排别的部分完成工作,进行调度,接收其他组件返回的成功与否的信号,然后向别的组件发送是否能进行工作的信号。 itempipeline:在管道中定制数据的结构 downloader:用来下载引擎发送过来的所有request请求,并将其获得的response交还给引擎,由引擎交给spider来执行。 scheduler:接受引擎发送过来的request请求,并按照一定的方式进行整理排列,入队.原创 2021-07-22 09:51:21 · 120 阅读 · 0 评论 -
用Xpath爬猪八戒网
step1:用request模块获取网页源代码 import requests keyword = input("输入爬取的关键字:") url = r"https://xian.zbj.com/search/f/?type=new&kw=%s"%keyword resp = requests.get(url) step2:分析页面源代码中是否有对应数据 step3: 用xpath进行解析 from lxml import etree tree = etree.HTML(resp.t原创 2021-07-12 14:31:45 · 371 阅读 · 0 评论 -
Xpath解析
一、原理 XPath是在xml中搜索内容的一门语言,html是xml语言的一种子集。 xml的例子: <book> <id>1</id> <name>追风筝的人</name> <author> <nick>卡勒德·胡赛尼</nick> <nike>Khaled Hosseini</nick> </author&g原创 2021-07-02 18:40:53 · 265 阅读 · 0 评论 -
bs4解析
step1: 安装 pip install bs4 -i +镜像 step2:使用 1. 获取页面源代码 2. BeautifulSoup解析(成树结构),将页面源代码交给BeautifulSoup解析,将解析器设置为html.parser 3. 使用find/find_all函数查找标签 find(标签,属性=值) find_all(标签,属性=值) step3:代码实现 import requests from bs4 import BeautifulSoup def spier()原创 2021-07-01 09:37:48 · 138 阅读 · 0 评论 -
豆瓣电影Top250
一、网页分析 内容属于fu'wu'qi原创 2021-06-20 18:01:06 · 127 阅读 · 0 评论 -
Re模块解析
一、Re正则表达式 一种使用表达式的方式对字符串进行匹配的语法规则。 抓取到的网页源代码实际上就是一个超长的zi'fu'ch原创 2021-06-20 17:29:27 · 107 阅读 · 0 评论 -
爬虫(四)
豆瓣电影 一、网页分析 获取方式是get 二、重新封装参数 url = "https://movie.douban.com/j/chart/top_list" ## get的url参数多时 param = { "type": "24", "interval_id": "100:90", "action": "", "start": 0, "limit": 20 } res原创 2021-05-12 16:42:48 · 58 阅读 · 0 评论 -
爬虫学习(三)
百度翻译爬取 Post 一、查看抓包工具network 访问方式为post,使用form data发送查询数据,获取链接为https://fanyi.baidu.com/sug。 二、代码 url = r'https://fanyi.baidu.com/sug' kword = input("输入查询单词") data = { "kw" : kword } ## post请求发送的数据必须放在字典中 resp = requests.pos原创 2021-05-12 10:29:57 · 55 阅读 · 0 评论 -
爬虫学习(二)
Requests模块 安装:pip install requests 镜像安装:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests 一、代码: import requests def pracRequests(): url = r'https://www.sogou.com/web?query=许嵩' resp = requests.get(url) ## 获得响应 print(resp原创 2021-05-12 10:13:55 · 428 阅读 · 1 评论 -
爬虫学习(一)
爬虫学习(一) 爬虫:程序模拟浏览器,输入网址,从该网址中获取资源或内容。 使用python库 urllib.request.urlopen 一、Web请求全过程剖析 1.服务器渲染:用户申请后,在服务器上将数据和html整合,统一返回浏览器。页面源代码中有数据。 2.客户端(浏览器)渲染:用户申请后,返回html骨架,用脚本再次申请数据,获得返回后填入html骨架进行展示。页面源代码中没有数据。获取数据需要找到二次请求的url,一般用浏览器的抓包工具进行分析。 二、HTTP..原创 2021-04-24 21:13:04 · 65 阅读 · 0 评论