当前位置: 首页 > news >正文

网络爬虫部分应掌握的重要知识点

目录

    • 一、预备知识
      • 1、Web基本工作原理
      • 2、网络爬虫的Robots协议
    • 二、爬取网页
      • 1、请求服务器并获取网页
      • 2、查看服务器端响应的状态码
      • 3、输出网页内容
    • 三、使用BeautifulSoup定位网页元素
      • 1、首先需要导入BeautifulSoup库
      • 2、使用find/find_all函数查找所需的标签元素
    • 四、获取元素的属性值
    • 五、获取元素包含的文本
      • 1、使用get_text属性查看该元素所包含的html文本
      • 2、使用text属性查看该元素及子孙元素包含的文本(可能包含空白字符)
      • 3、使用stripped_strings属性查看元素及其子孙包含的不带空白字符的文本
    • 六、遍历文档元素
    • 七、练习

一、预备知识

1、Web基本工作原理

Web 服务是互联网提供的 World wide Web 服务的简称,最简单的 Web 服务是如下的2层体系结构:
Alt
这种浏览器和 Web 服务器交的体系结构也称为 B/S 结构,文本、图片等信息在请求到达之前即通过 HTML 语言以静态网页形式存储在 Web 服务器上,HTTP 请求到达后,Web 服务器把网页发给客户端的浏览器进行响应,属于静态网页技术。

2、网络爬虫的Robots协议

Robots 协议:在网站根目录下的 robots.txt 文件,用于告知网络爬虫哪些页面可以抓取,哪些不行,例如:http://baidu.com/robots.txt Robots 协议是建议但非约束性,网络爬虫可以不遵守,但存在法律风险。

二、爬取网页

1、请求服务器并获取网页

假设要使用Requests库爬取网址为 http://httpbin.org/ 的网页内容,主要步骤包括:
(1)导入requests
(2)调用requests.get()方法获取网页

import requests
url='http://httpbin.org/'
response = requests.get(url=url)

2、查看服务器端响应的状态码

response.status_code

运行结果:

200

status_code等于200,表示浏览器正确获取了服务器端传递过来的网页。

3、输出网页内容

print(response.text)

运行结果:

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><title>httpbin.org</title><link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700"rel="stylesheet"><link rel="stylesheet" type="text/css" href="/flasgger_static/swagger-ui.css"><link rel="icon" type="image/png" href="/static/favicon.ico" sizes="64x64 32x32 16x16" /><style>html {box-sizing: border-box;overflow: -moz-scrollbars-vertical;overflow-y: scroll;}*,*:before,*:after {box-sizing: inherit;}body {margin: 0;background: #fafafa;}</style>
</head><body><a href="https://github.com/requests/httpbin" class="github-corner" aria-label="View source on Github"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;"aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"fill="currentColor" class="octo-body"></path></svg></a><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0"><defs><symbol viewBox="0 0 20 20" id="unlocked"><path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path></symbol><symbol viewBox="0 0 20 20" id="locked"><path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/></symbol><symbol viewBox="0 0 20 20" id="close"><path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/></symbol><symbol viewBox="0 0 20 20" id="large-arrow"><path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/></symbol><symbol viewBox="0 0 20 20" id="large-arrow-down"><path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/></symbol><symbol viewBox="0 0 24 24" id="jump-to"><path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z" /></symbol><symbol viewBox="0 0 24 24" id="expand"><path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z" /></symbol></defs></svg><div id="swagger-ui"><div data-reactroot="" class="swagger-ui"><div><div class="information-container wrapper"><section class="block col-12"><div class="info"><hgroup class="main"><h2 class="title">httpbin.org<small><pre class="version">0.9.2</pre></small></h2><pre class="base-url">[ Base URL: httpbin.org/ ]</pre></hgroup><div class="description"><div class="markdown"><p>A simple HTTP Request &amp; Response Service.<br><br><b>Run locally: </b><code>$ docker run -p 80:80 kennethreitz/httpbin</code></p></div></div><div><div><a href="https://kennethreitz.org" target="_blank">the developer - Website</a></div><a href="mailto:me@kennethreitz.org">Send email to the developer</a></div></div><!-- ADDS THE LOADER SPINNER --><div class="loading-container"><div class="loading"></div></div></section></div></div></div></div><div class='swagger-ui'><div class="wrapper"><section class="clear"><span style="float: right;">[Powered by<a target="_blank" href="https://github.com/rochacbruno/flasgger">Flasgger</a>]<br></span></section></div></div><script src="/flasgger_static/swagger-ui-bundle.js"> </script><script src="/flasgger_static/swagger-ui-standalone-preset.js"> </script><script src='/flasgger_static/lib/jquery.min.js' type='text/javascript'></script><script>window.onload = function () {fetch("/spec.json").then(function (response) {response.json().then(function (json) {var current_protocol = window.location.protocol.slice(0, -1);if (json.schemes[0] != current_protocol) {// Switches scheme to the current in usevar other_protocol = json.schemes[0];json.schemes[0] = current_protocol;json.schemes[1] = other_protocol;}json.host = window.location.host;  // sets the current hostconst ui = SwaggerUIBundle({spec: json,validatorUrl: null,dom_id: '#swagger-ui',deepLinking: true,jsonEditor: true,docExpansion: "none",apisSorter: "alpha",//operationsSorter: "alpha",presets: [SwaggerUIBundle.presets.apis,// yay ES6 modules ↘Array.isArray(SwaggerUIStandalonePreset) ? SwaggerUIStandalonePreset : SwaggerUIStandalonePreset.default],plugins: [SwaggerUIBundle.plugins.DownloadUrl],// layout: "StandaloneLayout"  // uncomment to enable the green top header})window.ui = ui// uncomment to rename the top brand if layout is enabled// $(".topbar-wrapper .link span").replaceWith("<span>httpbin</span>");})})
}</script>  <div class='swagger-ui'><div class="wrapper"><section class="block col-12 block-desktop col-12-desktop"><div><h2>Other Utilities</h2><ul><li><a href="/forms/post">HTML form</a> that posts to /post /forms/post</li></ul><br /><br /></div></section></div>
</div>
</body></html>

三、使用BeautifulSoup定位网页元素

下面给出部分网页内容,用于演示如何使用BeautifulSoup查找网页上需要的内容。

html='''<html><head><title>The Dormouse's story</title></head><body><p class="title"><b>The Dormouse's story</b></p><p class="story">Once upon a time there were three little sisters; and their names were<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>,<a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>and<a class="sister" href="http://example.com/tillie" id="link2">Tillie</a>; and they lived at the bottom of a well.</p><p class="story">爱丽丝梦游仙境</p></body></html>'''

1、首先需要导入BeautifulSoup库

参数说明:html就是上面的html文档字符串,'html.parser'指明了解析该文档字符串的解析器是html解析器。

from bs4 import BeautifulSoup
soup=BeautifulSoup(html,'html.parser')

Alt

基本元素说明
Tag标签,最基本的信息组织单元,分别用<>和</>标明开头和结尾
Name标签的名字,<p>...</p>的名字是’p’,格式:<tag>.name
Attributes标签的属性,字典形式组织,格式:<tag>.attrs
NavigableString标签内非属性字符串,<>...</>中字符串,格式:<tag>.string

2、使用find/find_all函数查找所需的标签元素

(1)认识html的标签元素
Alt
上面一整行是img标签,它由开始标签和结束标签两部分构成,标签名是img,它含有srcsize两个属性。

(2)find函数用于寻找满足条件的第一个标签

查看find函数的帮助信息:

soup.find?

运行结果:

Signature: soup.find(name=None, attrs={}, recursive=True, text=None, **kwargs)
Docstring:
Return only the first child of this Tag matching the given
criteria.
File:      d:\dell\appdata\anaconda3\lib\site-packages\bs4\element.py
Type:      method

查找文档中的第一个<p>元素/标签:

first_p=soup.find("p")
first_p

运行结果:

<p class="title">
<b>The Dormouse's story</b>
</p>

(3)查看找到的元素类型和属性

#输出找到的元素类型,是bs4.element.Tag类型
print(type(first_p))
#输出找到的元素的属性,是一个字典
first_p.attrs

运行结果:

<class 'bs4.element.Tag'>
{'class': ['title']}

(4)find_all函数用于寻找满足条件的所有标签,这些标签将被放入一个列表中

find_all函数的原型如下:

find_all(self, name=None attrs=f, recursive=True, text=None, limit=None, **kwargs)

self表明它是一个类成员函数;
name是要查找的tag元素名称,默认是None,如果不提供,就是查找所有的元素;
attrs是元素的属性,它是一个字典,默认是空,如果提供就是查找有这个指定属性的元素;
recursive指定查找是否在元素节点的子树下面全范围进行,默认是True
后面的textlimitkwargs参数比较复杂,将在后面用到时介绍;
find_all函数返回查找到的所有指定的元素的列表,每个元素是一个 bs4.element.Tag对象。

查找文档中的所有<a>元素:

a_ls=soup.find_all('a')
for a in a_ls:print(a)

运行结果:

<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>
<a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>
<a class="sister" href="http://example.com/tillie" id="link2">Tillie</a>

(5)查找文档中class='story’的p元素

p_story=soup.find_all('p',attrs={"class":"story"})
p_story

运行结果:

[<p class="story">Once upon a time there were three little sisters; and their names were<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>,<a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>and<a class="sister" href="http://example.com/tillie" id="link2">Tillie</a>; and they lived at the bottom of a well.</p>, <p class="story">爱丽丝梦游仙境</p>]

(6)练习:请找出文档中class='sister’的元素

all_sister=soup.find_all(attrs={"class":"sister"})
all_sister

运行结果:

[<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>, <a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>, <a class="sister" href="http://example.com/tillie" id="link2">Tillie</a>]

四、获取元素的属性值

(1)判断元素是否含有某属性

#判断文档中的第一个<p>元素是否含有class属性
first_p.has_attr("class")

运行结果:

True

(2)得到元素的属性值

因为属性名和值构成字典,所以采用字典的访问形式得到属性值。

#输出文档中所有<a>元素的href属性值:
a_ls=soup.find_all('a')
for a in a_ls:print(a["href"])

运行结果:

http://example.com/elsie
http://example.com/lacie
http://example.com/tillie

五、获取元素包含的文本

先找到class='story'的第一个p元素。

p_story_fst=soup.find('p',attrs={"class":"story"})

1、使用get_text属性查看该元素所包含的html文本

print(p_story_fst.get_text)

运行结果:

<bound method Tag.get_text of <p class="story">Once upon a time there were three little sisters; and their names were<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>,<a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>and<a class="sister" href="http://example.com/tillie" id="link2">Tillie</a>; and they lived at the bottom of a well.</p>>

2、使用text属性查看该元素及子孙元素包含的文本(可能包含空白字符)

p_story_fst.text

运行结果:

'\n    Once upon a time there were three little sisters; and their names were\n    \n     Elsie\n    \n    ,\n    \n     Lacie\n    \n    and\n    \n     Tillie\n    \n    ; and they lived at the bottom of a well.\n   '

3、使用stripped_strings属性查看元素及其子孙包含的不带空白字符的文本

list(p_story_fst.stripped_strings)

运行结果:

['Once upon a time there were three little sisters; and their names were','Elsie',',','Lacie','and','Tillie','; and they lived at the bottom of a well.']

六、遍历文档元素

Alt
(1)先找到class='story’的第一个p元素

p_story_fst=soup.find('p',attrs={"class":"story"})
p_story_fst

运行结果:

<p class="story">Once upon a time there were three little sisters; and their names were<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>,<a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>and<a class="sister" href="http://example.com/tillie" id="link2">Tillie</a>; and they lived at the bottom of a well.</p>

(2)向下遍历找到孩子元素

for child in p_story_fst.children:print(child)

运行结果:

Once upon a time there were three little sisters; and their names were<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>,<a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>and<a class="sister" href="http://example.com/tillie" id="link2">Tillie</a>; and they lived at the bottom of a well.

(3)向上遍历找到父亲元素

parnt=p_story_fst.parent
parnt.name

运行结果:

'body'

(4)平行遍历找到前面的兄弟节点

list(p_story_fst.previous_siblings)

运行结果:

['\n', <p class="title"><b>The Dormouse's story</b></p>, '\n']

(5)平行遍历找到后面的兄弟节点

list(p_story_fst.next_siblings)

运行结果:

['\n', <p class="story">爱丽丝梦游仙境</p>, '\n']

七、练习

test='''<html><head></head><body><span>1234 
<a href="www.test.edu.cn">This is a test!<b>abc</b></a></span> 
</body></html>''' 

(1)写出导入BeautifulSoup库和创建BeautifulSoup对象的代码:

from bs4 import BeautifulSoup 
soup=BeautifulSoup(test,'html.parser')

(2)完善代码,使得pos能定位到(指向)上述html代码中的span元素节点:

pos=soup.find('span')
pos

运行结果:

<span>1234 
<a href="www.test.edu.cn">This is a test!<b>abc</b></a></span>

(3)完善代码,能输出span元素内部包含的所有文本(包含子孙元素的文本):

print(pos.get_text())

运行结果:

1234 
This is a test!abc

(4)完善代码,能输出span元素后面直接包含的文本(不包含子孙元素的文本):

print(pos.next_sibling.string.strip())

运行结果:


(5)找出a元素的孩子和父亲节点名称

# 定位到a元素节点
a_tag=soup.find('a')# 输出a元素的孩子节点名称
for child in a_tag.children:print("Child node name:", child.name)# 输出a元素的父亲节点名称
print("Parent node name:", a_tag.parent.name)

运行结果:

Child node name: None
Child node name: b
Parent node name: span

(6)找出a元素包含的超链接信息

# 定位到a元素节点
a_tag=soup.find('a')# 获取超链接的URL
link_url=a_tag.get('href')
print("Link URL:", link_url)# 获取超链接文本
link_text=a_tag.get_text()
print("Link Text:", link_text)

运行结果:

Link URL: www.test.edu.cn
Link Text: This is a test!abc

(7)找出a元素包含的兄弟信息

# 定位到a元素节点
a_tag=soup.find('a')# 获取下一个兄弟节点的文本内容
next_sibling_text=a_tag.next_sibling.string.strip()
if a_tag.next_sibling else None
print("Next Sibling Text:", next_sibling_text)# 获取上一个兄弟节点的文本内容
prev_sibling_text=a_tag.previous_sibling.string.strip()
if a_tag.previous_sibling else None
print("Previous Sibling Text:", prev_sibling_text)

运行结果:

Next Sibling Text: None
Previous Sibling Text: 1234

相关文章:

网络爬虫部分应掌握的重要知识点

目录 一、预备知识1、Web基本工作原理2、网络爬虫的Robots协议 二、爬取网页1、请求服务器并获取网页2、查看服务器端响应的状态码3、输出网页内容 三、使用BeautifulSoup定位网页元素1、首先需要导入BeautifulSoup库2、使用find/find_all函数查找所需的标签元素 四、获取元素的…...

git命令笔记

文章目录 0、参考文档1、常用指令git checkout系列git pull系列git push系列git reset系列git branch系列git log系列git revert 撤销某次提交git diff其他 2、查看和修改用户名和邮箱&#xff0c;生成密钥other 0、参考文档 Git使用教程&#xff1a;最详细、最傻瓜、最浅显、…...

微服务day03-Nacos配置管理与Nacos集群搭建

一.Nacos配置管理 Nacos不仅可以作为注册中心&#xff0c;可以进行配置管理 1.1 统一配置管理 统一配置管理可以实现配置的热更新&#xff08;即不用重启当服务发生变更时也可以直接更新&#xff09; dataId格式&#xff1a;服务名-环境名.yaml&#xff0c;分组一般使用默认…...

DFS剪枝

剪枝 将搜索过程中一些不必要的部分剔除掉&#xff0c;因为搜索过程构成了一棵树&#xff0c;剔除不必要的部分&#xff0c;就像是在树上将树枝剪掉&#xff0c;故名剪枝。 剪枝是回溯法中的一种重要优化手段&#xff0c;方法往往先写一个暴力搜索&#xff0c;然后找到某些特…...

基于SpringBoot多模块项目引入其他模块时@Autowired无法注入

基于SpringBoot多模块项目引入其他模块时Autowired无法注入 一、问题描述1、解决方案 一、问题描述 启动Spring Boot项目时报 Could not autowire. No beans of ‘xxxxxxxx’ type found. 没有找到bean的实例&#xff0c;即spring没有实例化对象&#xff0c;也就无法根据配置文…...

每日一题——LeetCode1566.重复至少K次且长度为M的模式

方法一 暴力枚举 var containsPattern function(arr, m, k) {const n arr.length;for (let l 0; l < n - m * k; l) {let offset;for (offset 0; offset < m * k; offset) {if (arr[l offset] ! arr[l offset % m]) {break;}}if (offset m * k) {return true;}}r…...

代码随想录刷题笔记-Day27

1. 全排列 46. 全排列https://leetcode.cn/problems/permutations/ 给定一个不含重复数字的数组 nums &#xff0c;返回其 所有可能的全排列 。你可以 按任意顺序 返回答案。 示例 1&#xff1a; 输入&#xff1a;nums [1,2,3] 输出&#xff1a;[[1,2,3],[1,3,2],[2,1,3],…...

【小沐学GIS】QGIS安装和入门使用

文章目录 1、简介2、下载和安装3、使用3.1 XYZ Tiles3.2 WMS / WMTS3.3 GeoJson文件加载 4、在线资源结语 1、简介 QGIS是一款开源地理信息系统。该项目于2002年5月诞生&#xff0c;同年6月作为SourceForge上的一个项目建立。QGIS目前运行在大多数Unix平台、Windows和macOS上。…...

黑马程序员——接口测试——day03——Postman断言、关联、参数化

目录&#xff1a; Potman断言 Postman断言简介Postman常用断言 断言响应状态码断言包含某字符串断言JSON数据Postman断言工作原理Postman关联 简介实现步骤核心代码创建环境案例1案例2Postman参数化 简介数据文件简介编写数据文件 CSV文件JSON文件导入数据文件到postman读取数…...

Unreal触屏和鼠标控制旋转冲突问题

Unreal触屏和鼠标控制旋转冲突问题 鼠标控制摄像机旋转添加Input轴计算旋转角度通过轴事件控制旋转 问题和原因问题原因 解决办法增加触摸控制旋转代码触屏操作下屏蔽鼠标轴响应事件 鼠标控制摄像机旋转 通过Mouse X和Mouse Y控制摄像机旋转。 添加Input轴 计算旋转角度 通过…...

Vins-Moon配准运行

Vins-Moon运行 求助&#xff01;&#xff01;&#xff01;源码地址电脑配置环境配置编译Kitti数据集制作IMU时间戳问题 适配Kitti数据集运行结果Euroc数据集kitti数据集 evo评估&#xff08;KITTI数据&#xff09;输出轨迹(tum格式)结果 求助&#xff01;&#xff01;&#xff…...

MSCKF3讲:后端理论推导(上)

MSCKF3讲&#xff1a;后端理论推导&#xff08;上&#xff09; 文章目录 MSCKF3讲&#xff1a;后端理论推导&#xff08;上&#xff09;1 MSCKF中的状态变量① IMU状态:② cam0状态&#xff1a;③ IMU和cam0间状态关系 2 微分方程递推&#xff08;数值解&#xff09;3 IMU状态预…...

群控代理IP搭建教程:打造一流的网络爬虫

目录 前言 一、什么是群控代理IP&#xff1f; 二、搭建群控代理IP的步骤 1. 获取代理IP资源 2. 配置代理IP池 3. 选择代理IP策略 4. 编写代理IP设置代码 5. 异常处理 三、总结 前言 群控代理IP是一种常用于网络爬虫的技术&#xff0c;通过使用多个代理IP实现并发请求…...

【IO流系列】字符流练习(拷贝、文件加密、修改文件数据)

字符流练习 练习1&#xff1a;文件夹拷贝1.1 需求1.2 代码实现1.3 输出结果 练习2&#xff1a;文件加密与解密2.1 需求2.2 代码实现2.3 输出结果 练习3&#xff1a;修改文件数据&#xff08;常规方法&#xff09;3.1 需求3.2 代码实现3.3 输出结果 练习4&#xff1a;修改文件数…...

华为云磁盘挂载

华为云磁盘挂载 磁盘挂载情况 fdisk -l 2. 查看当前分区情况 df -h 3.给新硬盘添加新分区 fdisk /dev/vdb 4.分区完成&#xff0c;查询所有设备的文件系统类型 blkid 发现新分区并没有文件系统类型&#xff08;type为文件系统具体类型&#xff0c;有ext3,ext4,xfs,iso9660等…...

通过大语言模型理解运维故障:评估和总结

张圣林 南开大学软件学院副教授、博士生导师 第六届CCF国际AIOps挑战赛程序委员会主席 在ATC、WWW、VLDB、KDD、SIGMETRICS等国际会议和JSAC、TC、TSC等国际期刊发表高水平论文50余篇。主持国家自然科学基金项目2项&#xff0c;横向项目13项&#xff08;与华为、字节跳动、腾讯…...

SVN教程-SVN的基本使用

SVN&#xff08;Apache Subversion&#xff09;是一款强大的集中式版本控制系统&#xff0c;它在软件开发项目中扮演着至关重要的角色&#xff0c;用于有效地跟踪、记录和管理代码的演变过程。与分布式系统相比&#xff0c;SVN 的集中式架构使得团队能够更加协同地进行开发&…...

【MySQL】数据查询——DQL基本数据库查询

目录 查询语法1. 查询表中所有的数据行和列&#xff0c;采用“*”符号2. 查询表中指定列的数据。3. 在查询中使用别名&#xff0c;使用“AS”关键字。4. 在查询中使用常量列&#xff1a;如果需要将一些常量的默认信息添加到输出结果中&#xff0c;以方便统计或计算。可以使用常…...

机器人持续学习基准LIBERO系列9——数据集轨迹查看

0.前置 机器人持续学习基准LIBERO系列1——基本介绍与安装测试机器人持续学习基准LIBERO系列2——路径与基准基本信息机器人持续学习基准LIBERO系列3——相机画面可视化及单步移动更新机器人持续学习基准LIBERO系列4——robosuite最基本demo机器人持续学习基准LIBERO系列5——…...

uniapp中canvas的基础使用

canvas简介 canvas是uniapp中提供的一个组件,用于生成自定义的图形界面。通过canvas,我们可以通过JavaScript代码在页面上绘制各种图形和图像。 使用canvas 在页面中添加canvas 首先需要在页面的template中添加一个canvas组件: <template><view><canvas ca…...

HTML 语义化

目录 HTML 语义化HTML5 新特性HTML 语义化的好处语义化标签的使用场景最佳实践 HTML 语义化 HTML5 新特性 标准答案&#xff1a; 语义化标签&#xff1a; <header>&#xff1a;页头<nav>&#xff1a;导航<main>&#xff1a;主要内容<article>&#x…...

label-studio的使用教程(导入本地路径)

文章目录 1. 准备环境2. 脚本启动2.1 Windows2.2 Linux 3. 安装label-studio机器学习后端3.1 pip安装(推荐)3.2 GitHub仓库安装 4. 后端配置4.1 yolo环境4.2 引入后端模型4.3 修改脚本4.4 启动后端 5. 标注工程5.1 创建工程5.2 配置图片路径5.3 配置工程类型标签5.4 配置模型5.…...

GitHub 趋势日报 (2025年06月08日)

&#x1f4ca; 由 TrendForge 系统生成 | &#x1f310; https://trendforge.devlive.org/ &#x1f310; 本日报中的项目描述已自动翻译为中文 &#x1f4c8; 今日获星趋势图 今日获星趋势图 884 cognee 566 dify 414 HumanSystemOptimization 414 omni-tools 321 note-gen …...

Linux C语言网络编程详细入门教程:如何一步步实现TCP服务端与客户端通信

文章目录 Linux C语言网络编程详细入门教程&#xff1a;如何一步步实现TCP服务端与客户端通信前言一、网络通信基础概念二、服务端与客户端的完整流程图解三、每一步的详细讲解和代码示例1. 创建Socket&#xff08;服务端和客户端都要&#xff09;2. 绑定本地地址和端口&#x…...

比较数据迁移后MySQL数据库和OceanBase数据仓库中的表

设计一个MySQL数据库和OceanBase数据仓库的表数据比较的详细程序流程,两张表是相同的结构,都有整型主键id字段,需要每次从数据库分批取得2000条数据,用于比较,比较操作的同时可以再取2000条数据,等上一次比较完成之后,开始比较,直到比较完所有的数据。比较操作需要比较…...

TSN交换机正在重构工业网络,PROFINET和EtherCAT会被取代吗?

在工业自动化持续演进的今天&#xff0c;通信网络的角色正变得愈发关键。 2025年6月6日&#xff0c;为期三天的华南国际工业博览会在深圳国际会展中心&#xff08;宝安&#xff09;圆满落幕。作为国内工业通信领域的技术型企业&#xff0c;光路科技&#xff08;Fiberroad&…...

Cilium动手实验室: 精通之旅---13.Cilium LoadBalancer IPAM and L2 Service Announcement

Cilium动手实验室: 精通之旅---13.Cilium LoadBalancer IPAM and L2 Service Announcement 1. LAB环境2. L2公告策略2.1 部署Death Star2.2 访问服务2.3 部署L2公告策略2.4 服务宣告 3. 可视化 ARP 流量3.1 部署新服务3.2 准备可视化3.3 再次请求 4. 自动IPAM4.1 IPAM Pool4.2 …...

【安全篇】金刚不坏之身:整合 Spring Security + JWT 实现无状态认证与授权

摘要 本文是《Spring Boot 实战派》系列的第四篇。我们将直面所有 Web 应用都无法回避的核心问题&#xff1a;安全。文章将详细阐述认证&#xff08;Authentication) 与授权&#xff08;Authorization的核心概念&#xff0c;对比传统 Session-Cookie 与现代 JWT&#xff08;JS…...

软件工程 期末复习

瀑布模型&#xff1a;计划 螺旋模型&#xff1a;风险低 原型模型: 用户反馈 喷泉模型:代码复用 高内聚 低耦合&#xff1a;模块内部功能紧密 模块之间依赖程度小 高内聚&#xff1a;指的是一个模块内部的功能应该紧密相关。换句话说&#xff0c;一个模块应当只实现单一的功能…...

DAY 26 函数专题1

函数定义与参数知识点回顾&#xff1a;1. 函数的定义2. 变量作用域&#xff1a;局部变量和全局变量3. 函数的参数类型&#xff1a;位置参数、默认参数、不定参数4. 传递参数的手段&#xff1a;关键词参数5 题目1&#xff1a;计算圆的面积 任务&#xff1a; 编写一…...