Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
pythonjavaphpc
python_spider
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
python_spider
/
utils
/
parser.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
22 lines (18 loc) · 1.28 KB
master
Breadcrumbs
python_spider
/
utils
/
parser.py
Copy path
Top
File metadata and controls
Code
Blame
22 lines (18 loc) · 1.28 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import
argparse
def
get_args
():
# 参数处理
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'-u'
,
dest
=
"url"
,
default
=
""
,
help
=
"爬虫起始地址"
)
parser
.
add_argument
(
"-d"
,
type
=
int
,
dest
=
"deep"
,
default
=
0
,
help
=
"爬取深度,起始地址为第0级"
)
parser
.
add_argument
(
"--thread"
,
type
=
int
,
dest
=
"thread"
,
default
=
10
,
help
=
"爬虫使用的线程数"
)
parser
.
add_argument
(
'--dbfile'
,
dest
=
"dbfile"
,
default
=
"spider.db"
,
help
=
"存放数据库(sqlite)文件名"
)
parser
.
add_argument
(
'-f'
,
dest
=
"logfile"
,
default
=
"spider.log"
,
help
=
"日志文件名"
)
parser
.
add_argument
(
'-l'
,
dest
=
"loglevel"
,
default
=
"5"
,
type
=
int
,
help
=
"日志记录文件记录详细程度,数字越大记录越详细(1-5)"
)
parser
.
add_argument
(
'--key'
,
dest
=
"key"
,
default
=
""
,
help
=
"页面内的关键词,获取满足该关键词的网页,不指定关键字时获取所有页面"
)
parser
.
add_argument
(
'--encoding'
,
dest
=
"encoding"
,
default
=
None
,
help
=
"指定页面编码,如果不指定将自动测试页面编码"
)
parser
.
add_argument
(
'--testself'
,
action
=
"store_true"
,
dest
=
"testself"
,
default
=
""
,
help
=
"程序自测自测"
)
args
=
parser
.
parse_args
()
args
.
key
=
args
.
key
.
decode
(
"utf-8"
)
return
args
You can’t perform that action at this time.