Skip to content

Commit ab8f4d4

Browse files
committed
update
update
1 parent e1c563e commit ab8f4d4

2 files changed

Lines changed: 68 additions & 10 deletions

File tree

spiders/main.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
## Python爬虫
2-
1. [Python爬虫之requests库](Python爬虫之requests库.md)
3-
4-
2. [Python爬虫之BeautifulSoup](Python爬虫之BeautifulSoup.md)
5-
3. [Python爬虫之xpath解析](Python爬虫xpath解析.md)
6-
4. [Python爬虫之selenium自动化](Python爬虫之selenium自动化.md)
7-
5. [Python爬虫之构建自己的代理IP池](Python爬虫之构建自己的代理IP池.md)
8-
6. [Python爬虫之知乎钓鱼贴图片爬取](Python爬虫之知乎钓鱼贴图片爬取.md)
9-
7. [Python爬虫之uiautomator2常用操作](Python爬虫之uiautomator2常用操作.md)
10-
8. [python爬虫之一尘论坛发帖数据爬取](python爬虫之一尘论坛发帖数据爬取.md)
11-
9. [python爬虫之网易云音乐歌单歌曲列表及热门评论数据抓取](python爬虫之网易云音乐.md)
2+
* [Python爬虫之requests库](Python爬虫之requests库.md)
3+
* [Python爬虫之BeautifulSoup](Python爬虫之BeautifulSoup.md)
4+
* [Python爬虫之xpath解析](Python爬虫xpath解析.md)
5+
* [Python爬虫之selenium自动化](Python爬虫之selenium自动化.md)
6+
* [Python爬虫之构建自己的代理IP池](Python爬虫之构建自己的代理IP池.md)
7+
* [Python爬虫之知乎钓鱼贴图片爬取](Python爬虫之知乎钓鱼贴图片爬取.md)
8+
* [Python爬虫之uiautomator2常用操作](Python爬虫之uiautomator2常用操作.md)
9+
* [python爬虫之一尘论坛发帖数据爬取](python爬虫之一尘论坛发帖数据爬取.md)
10+
* [python爬虫之网易云音乐歌单歌曲列表及热门评论数据抓取](python爬虫之网易云音乐.md)
11+
* [一些概念](概念.md)

spiders/概念.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## 1.robots协议
2+
也叫robots.txt,是存放在网站根目录下的文本文件,用来告诉搜索引擎该网站哪些内容是不应该被抓取的,哪些是可以抓取的。
3+
4+
https://www.csdn.net/robots.txt
5+
```python
6+
User-agent: *
7+
Disallow: /scripts
8+
Disallow: /public
9+
Disallow: /css/
10+
Disallow: /images/
11+
Disallow: /content/
12+
Disallow: /ui/
13+
Disallow: /js/
14+
Disallow: /scripts/
15+
Disallow: /article_preview.html*
16+
Disallow: /tag/
17+
Disallow: /*?*
18+
Disallow: /link/
19+
20+
Sitemap: https://www.csdn.net/sitemap-aggpage-index.xml
21+
Sitemap: https://www.csdn.net/article/sitemap.txt
22+
```
23+
## 2.常见的反爬虫措施
24+
#### 1.请求头校验
25+
一般网站会对请求头进行校验,比如Host,UA,Content-Type字段等,模拟请求的时候,这些常见的请求头最好是带上。
26+
#### 2.IP访问次数控制
27+
同一个IP地址短时间内大量发起请求,会引起IP限制,解决方法是用代理IP,或者构建自己的代理IP池。
28+
#### 3.接口请求频率限制
29+
有的网站会控制接口访问的频率,比如有些查询接口,控制两三秒访问一次。
30+
#### 4.接口访问次数限制
31+
每天限制某个IP或账号访问接口的次数,达到上限后出现二次验证或者直接封账号/IP.比如登录接口
32+
#### 5.行为认证
33+
请求次数过多会出现人工认证,如图片验证码,滑动认证,点击认证等,可以对接打码平台。
34+
#### 6,自动化环境检测
35+
selenium自动化工具有的网站会检测出来,大部分可以通过下面两种方式跳过检测,下面两种方式无法处理,还可以尝试把页面改为移动端页面(手机模式),最后还有一种方法就是代理服务器拦截修改js代码,把检测selenium的js修改掉。
36+
```python
37+
options = webdriver.ChromeOptions()
38+
# 躲避部分网站selenium检测
39+
options.add_experimental_option('excludeSwitches', ['enable-automation'])
40+
options.add_experimental_option("useAutomationExtension", False)
41+
42+
driver = webdriver.Chrome(executable_path=chromedriver_path, options=options)
43+
44+
# 躲避部分网站selenium检测
45+
script = "Object.defineProperty(navigator, 'webdriver', {get: () => undefined});"
46+
driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {"source": script})
47+
```
48+
49+
对于移动端appium的检测,可以尝试替换为uiautomator2实现自动化
50+
51+
#### 7.数据动态加载
52+
有的数据不是通过html页面的接口请求返回的,抓包分析请求,找到正确的数据接口。
53+
#### 8.请求参数加密
54+
网易云音乐的post请求的请求体就是前端经过js加密后计算得到的,需要逆向js代码
55+
#### 9.返回数据加密
56+
需要逆向js代码,分析如何解密。还有一种像大众点评的评论,需要通过定位去找到文本。
57+
#### 10.动态更新cookies
58+
华为手机云服务,每次请求接口都会重新设置cookies,并且请求头参数也需要跟着cookies一起变化

0 commit comments

Comments
 (0)