栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Java爬虫

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Java爬虫

Java爬虫

Web Crawler, 网络爬虫

1. HttpClient

Java的 HTTP 协议客户端 HttpClient这个技术, 来实现抓取网页数据

1, GET请求

2, 带参数的GET请求

3, POST请求

4, 带参数的POST请求

5, 连接池

6, 请求参数

https://mvnrepository.com/

httpclient

https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient/4.5.2

log4j

https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12/1.7.25

日志, 需要配置文件的, 所以 在 resources目录下, 新建一个 资源文件

2. Jsoup

1, 解析url

2, 解析字符串

3, 解析文件

4, 使用dom方式获取元素

5, 使用选择器获取元素

6, 使用组合选择器获取元素

2.1. 实例

1, 开发准备

2, 编写引导类, Service, Dao

3, 封装HttpClient

4, 实现爬虫功能1

5, 实现爬虫功能2

6, 实现爬虫功能3

配置参数, 配置请求信息

create table mall_item(
    id bigint(10) not null auto_increment comment '主键id',
    spu bigint(15) default null comment '商品集合id',
    sku bigint(15) default null comment '商品最小品类单元id',
    title varchar(100) default null comment '商品标题',
    price bigint(10) default null comment '商品价格',
    pic varchar(10) default null comment '商品图片',
    url varchar(200) default null comment '商品详情地址',
    created datetime default null comment '创建时间',
    updated datetime default null comment '更新时间',
    primary key(id),
    key sku (sku) using btree
) engine=InnoDB auto_increment=1 default charset=utf8 comment='商城商品表';
3. WebMagic

1, 搭建环境

2, 编写代码

3, 抽取元素

4, 获取链接

5, 使用Pipline保存数据

6, 爬虫的配置, 自动和终止

参考链接

https://www.bilibili.com/video/BV1V64y1s7p2

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/303135.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号