Skip to content

Commit 4c5b17e

Browse files
demo
1 parent aef6b48 commit 4c5b17e

File tree

17 files changed

+721
-4
lines changed

17 files changed

+721
-4
lines changed

.gitignore

Whitespace-only changes.

.idea/vcs.xml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AutoScraperX.egg-info/PKG-INFO

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
Metadata-Version: 2.1
2+
Name: AutoScraperX
3+
Version: 0.1.0
4+
Summary: A common spider tool based on Selenium
5+
Home-page: https://github.com/chenziying1/AutoScraperX
6+
Author: czy
7+
Author-email: 1060324818@qq.com
8+
Classifier: Programming Language :: Python :: 3
9+
Classifier: Operating System :: OS Independent
10+
Requires-Python: >=3.6
11+
Description-Content-Type: text/markdown
12+
Requires-Dist: selenium
13+
Requires-Dist: beautifulsoup4
14+
Requires-Dist: undetected-chromedriver
15+
16+
# AutoScraperX
17+
18+
AutoScraperX 是一个基于 Selenium 和 undetected_chromedriver 的通用爬虫框架,旨在提供强大而灵活的 Web 自动化功能。它支持自动化浏览、元素操作、页面截图、cookie 管理等功能,适用于各种爬取任务。
19+
20+
## 功能特点
21+
22+
* **支持多种浏览器选项**(无头模式、用户数据目录、自定义 Chrome 位置等)
23+
* **支持移动端仿真**(iPhone X 模拟)
24+
* **智能等待机制**,确保元素加载完毕再进行操作
25+
* **页面截图**,可保存完整网页截图
26+
* **Cookie 读写**,支持持久化登录
27+
* **自动滚动、刷新、切换标签页等操作**
28+
* **异常处理**,确保爬虫稳定运行
29+
30+
## 安装
31+
32+
确保你的环境中安装了以下依赖:
33+
34+
```
35+
pip install selenium undetected-chromedriver beautifulsoup4
36+
```
37+
38+
此外,请下载并配置相应的 WebDriver,例如 [ChromeDriver]()。
39+
40+
## 使用方法
41+
42+
### 初始化爬虫
43+
44+
```
45+
from common_spider import Spider
46+
47+
options = {
48+
'headless': True, # 以无头模式运行
49+
'binary_location': "C:\\Path\\To\\chrome.exe", # 指定 Chrome 位置
50+
'user_data_dir': "C:\\Users\\User\\AppData\\Local\\Google\\Chrome\\User Data",
51+
'driver_executable_path': "C:\\Path\\To\\chromedriver.exe"
52+
}
53+
54+
spider = Spider(options)
55+
```
56+
57+
### 打开网页
58+
59+
```
60+
spider.open("https://example.com")
61+
```
62+
63+
### 获取页面源码
64+
65+
```
66+
html = spider.get_source()
67+
print(html)
68+
```
69+
70+
### 等待元素加载
71+
72+
```
73+
spider.wait_element("//div[@id='content']", by=By.XPATH)
74+
```
75+
76+
### 进行交互
77+
78+
```
79+
spider.comment("测试评论", "#comment-box")
80+
```
81+
82+
### 保存截图
83+
84+
```
85+
spider.save_screenshot("screenshot.png")
86+
```
87+
88+
### 处理 Cookie
89+
90+
```
91+
spider.save_cookie("cookies.pkl")
92+
spider.load_cookie("cookies.pkl", domain="example.com")
93+
```
94+
95+
### 退出爬虫
96+
97+
```
98+
spider.quit()
99+
```
100+
101+
## 贡献
102+
103+
如果你对 AutoScraperX 有任何改进建议或贡献,请提交 PR 或 Issue。
104+
105+
## 联系方式
106+
107+
* 作者: czy
108+
* 邮箱: [1060324818@qq.com]()
109+
* 项目地址:https://github.com/chenziying1/AutoScraperX
110+
* 项目示例:https://github.com/chenziying1/AutoScraperX/test/test.py

AutoScraperX.egg-info/SOURCES.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
README.md
2+
setup.py
3+
AutoScraperX/__init__.py
4+
AutoScraperX/common_spider.py
5+
AutoScraperX/utils.py
6+
AutoScraperX.egg-info/PKG-INFO
7+
AutoScraperX.egg-info/SOURCES.txt
8+
AutoScraperX.egg-info/dependency_links.txt
9+
AutoScraperX.egg-info/requires.txt
10+
AutoScraperX.egg-info/top_level.txt
11+
test/test.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

AutoScraperX.egg-info/requires.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
selenium
2+
beautifulsoup4
3+
undetected-chromedriver
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AutoScraperX

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# AutoScraperX
2+
3+
AutoScraperX 是一个基于 Selenium 和 undetected_chromedriver 的通用爬虫框架,旨在提供强大而灵活的 Web 自动化功能。它支持自动化浏览、元素操作、页面截图、cookie 管理等功能,适用于各种爬取任务。
4+
5+
## 功能特点
6+
7+
* **支持多种浏览器选项**(无头模式、用户数据目录、自定义 Chrome 位置等)
8+
* **支持移动端仿真**(iPhone X 模拟)
9+
* **智能等待机制**,确保元素加载完毕再进行操作
10+
* **页面截图**,可保存完整网页截图
11+
* **Cookie 读写**,支持持久化登录
12+
* **自动滚动、刷新、切换标签页等操作**
13+
* **异常处理**,确保爬虫稳定运行
14+
15+
## 安装
16+
17+
确保你的环境中安装了以下依赖:
18+
19+
```
20+
pip install selenium undetected-chromedriver beautifulsoup4
21+
```
22+
23+
此外,请下载并配置相应的 WebDriver,例如 [ChromeDriver]()
24+
25+
## 使用方法
26+
27+
### 初始化爬虫
28+
29+
```
30+
from common_spider import Spider
31+
32+
options = {
33+
'headless': True, # 以无头模式运行
34+
'binary_location': "C:\\Path\\To\\chrome.exe", # 指定 Chrome 位置
35+
'user_data_dir': "C:\\Users\\User\\AppData\\Local\\Google\\Chrome\\User Data",
36+
'driver_executable_path': "C:\\Path\\To\\chromedriver.exe"
37+
}
38+
39+
spider = Spider(options)
40+
```
41+
42+
### 打开网页
43+
44+
```
45+
spider.open("https://example.com")
46+
```
47+
48+
### 获取页面源码
49+
50+
```
51+
html = spider.get_source()
52+
print(html)
53+
```
54+
55+
### 等待元素加载
56+
57+
```
58+
spider.wait_element("//div[@id='content']", by=By.XPATH)
59+
```
60+
61+
### 进行交互
62+
63+
```
64+
spider.comment("测试评论", "#comment-box")
65+
```
66+
67+
### 保存截图
68+
69+
```
70+
spider.save_screenshot("screenshot.png")
71+
```
72+
73+
### 处理 Cookie
74+
75+
```
76+
spider.save_cookie("cookies.pkl")
77+
spider.load_cookie("cookies.pkl", domain="example.com")
78+
```
79+
80+
### 退出爬虫
81+
82+
```
83+
spider.quit()
84+
```
85+
86+
## 贡献
87+
88+
如果你对 AutoScraperX 有任何改进建议或贡献,请提交 PR 或 Issue。
89+
90+
## 联系方式
91+
92+
* 作者: czy
93+
* 邮箱: [1060324818@qq.com]()
94+
* 项目地址:https://github.com/chenziying1/AutoScraperX
95+
* 项目示例:https://github.com/chenziying1/AutoScraperX/test/test.py

build/lib/AutoScraperX/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .common_spider import Spider
2+
from .utils import rm_space, random_id
3+
4+
__all__ = ["Spider", "rm_space", "random_id"]

0 commit comments

Comments
 (0)