MCPcopy Create free account

hub / github.com/NanmiCoder/CrawlerTutorial / functions

Functions724 in github.com/NanmiCoder/CrawlerTutorial

↓ 263 callersMethodinfo
获取数据集基本信息
源代码/爬虫进阶/10_数据分析与可视化/pandas_analysis.py:35
↓ 194 callersMethodget
GET 请求
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/session_demo.py:77
↓ 118 callersMethodappend
追加单条数据
源代码/爬虫进阶/11_进阶综合实战项目/store/backend.py:105
↓ 34 callersMethodrun
运行爬虫 Returns: 爬取结果
源代码/爬虫进阶/01_工程化爬虫开发规范/refactored_crawler/crawler.py:31
↓ 30 callersMethodnew_page
创建新页面
源代码/爬虫进阶/11_进阶综合实战项目/core/browser.py:124
↓ 17 callersMethodclose
关闭浏览器
源代码/爬虫进阶/07_登录认证_扫码与短信登录实现/sms_login.py:59
↓ 14 callersMethodclose
关闭浏览器
源代码/爬虫进阶/04_Playwright浏览器自动化入门/spa_crawler.py:66
↓ 14 callersMethodget
发送 GET 请求(带重试) Args: url: 请求 URL **kwargs: 传递给 httpx 的其他参数 Returns: httpx.Response 响应对象
源代码/爬虫进阶/01_工程化爬虫开发规范/refactored_crawler/client.py:70
↓ 12 callersMethodpost
POST 请求
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/session_demo.py:81
↓ 12 callersMethodsave
保存 Cookie
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/cookie_manager.py:269
↓ 10 callersMethodacquire
获取令牌 Args: tokens: 需要的令牌数 Returns: 实际等待的时间(秒)
源代码/爬虫进阶/02_反爬虫对抗基础_请求伪装/rate_limiter.py:44
↓ 9 callersMethodto_dict
转换为字典格式
源代码/爬虫进阶/11_进阶综合实战项目/models/bilibili.py:244
↓ 9 callersMethodupdate
更新 Cookie
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/cookie_manager.py:277
↓ 8 callersMethodclose
关闭浏览器
源代码/爬虫进阶/11_进阶综合实战项目/core/browser.py:132
↓ 8 callersMethodis_logged_in
检查是否已登录 Args: cookies: Cookie 字典 Returns: 是否已登录
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/login_state_checker.py:31
↓ 7 callersMethodget_random
获取随机 User-Agent(桌面端) Returns: 随机的 User-Agent 字符串
源代码/爬虫进阶/02_反爬虫对抗基础_请求伪装/ua_rotator.py:82
↓ 7 callersMethodstart
启动浏览器
源代码/爬虫进阶/07_登录认证_扫码与短信登录实现/sms_login.py:46
↓ 6 callersMethodadd_account
添加账号
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/cookie_manager.py:145
↓ 6 callersMethodload
加载 Cookie
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/cookie_manager.py:254
↓ 5 callersMethod_check_reset
检查是否需要重置(跨天)
源代码/爬虫进阶/08_验证码识别与处理/captcha_service.py:218
↓ 5 callersMethodcookies
获取当前 Cookie(不验证)
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/bilibili_cookie.py:313
↓ 5 callersMethodto_httpx_cookies
转换为 httpx 可用的字典格式
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/bilibili_cookie.py:103
↓ 4 callersMethod_proxy_key
生成代理唯一标识
源代码/爬虫进阶/03_代理IP的使用与管理/proxy_pool/pool.py:62
↓ 4 callersMethodclose
清理资源
源代码/爬虫进阶/07_登录认证_扫码与短信登录实现/login_factory.py:55
↓ 4 callersMethodcreate_status_code_checker
创建状态码检测器 Args: check_url: 检测 URL success_codes: 成功的状态码列表,默认 [200] timeout: 超时时间 Example
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/login_state_checker.py:156
↓ 4 callersMethodexecute
需要更新、写入等操作的 excute 执行语句 :param sql: :param args: :return:
源代码/爬虫入门/10_爬虫入门实战3_数据存储实现/async_db.py:88
↓ 4 callersMethodget_simhash
计算 SimHash(用于大规模去重) SimHash 是一种局部敏感哈希,相似文本的哈希值相近 Args: text: 文本内容 bits: 哈希位数 Returns:
源代码/爬虫进阶/09_数据清洗与预处理/deduplication.py:301
↓ 4 callersMethodget_valid_cookies
获取有效的 Cookie(自动检测和刷新) Returns: 简单字典格式的 Cookie,如 {"name": "value", ...}
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/cookie_manager.py:283
↓ 4 callersMethodnormalize_case
标准化大小写 Args: text: 输入文本 case: 大小写类型 (lower/upper/title/capitalize) Returns: 标准化后的文本
源代码/爬虫进阶/09_数据清洗与预处理/data_normalizer.py:275
↓ 4 callersMethodstart
启动爬虫 完整流程: 1. 启动浏览器 2. 执行登录 3. 初始化 API 客户端 4. 根据配置执行爬取 5. 关闭浏览器 Returns:
源代码/爬虫进阶/11_进阶综合实战项目/crawler/spider.py:65
↓ 4 callersMethodstop
停止代理池
源代码/爬虫进阶/03_代理IP的使用与管理/proxy_pool/pool.py:82
↓ 3 callersMethod_create_wordcloud
创建 WordCloud 对象
源代码/爬虫进阶/10_数据分析与可视化/wordcloud_generator.py:188
↓ 3 callersMethod_fetch_wbi_keys
从 API 获取 WBI 密钥(备用方案)
源代码/爬虫进阶/11_进阶综合实战项目/client/bilibili_client.py:118
↓ 3 callersMethod_refresh_cookies
刷新 Cookie
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/cookie_manager.py:344
↓ 3 callersMethod_request
发送 HTTP 请求 Args: method: 请求方法(GET/POST) url: 请求 URL params: URL 参数 data: POST 数据
源代码/爬虫进阶/11_进阶综合实战项目/client/bilibili_client.py:146
↓ 3 callersMethodbuild_api_headers
构建 API 请求头 Args: referer: Referer 地址(API 请求通常需要) origin: Origin 地址(POST 请求通常需要) content_type: Co
源代码/爬虫进阶/02_反爬虫对抗基础_请求伪装/headers_builder.py:92
↓ 3 callersMethodcan_use_service
是否可以使用打码服务
源代码/爬虫进阶/08_验证码识别与处理/captcha_service.py:206
↓ 3 callersMethodcreate_json_checker
创建 JSON 响应检测器 检测响应 JSON 中是否包含指定字段 Args: check_url: API 地址 success_field: 成功时 JSON 中存在的字段
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/login_state_checker.py:53
↓ 3 callersMethodfetch
获取页面/API 数据 Args: url: 目标 URL referer: Referer 地址 is_api: 是否是 API 请求 Returns:
源代码/爬虫进阶/02_反爬虫对抗基础_请求伪装/anti_detection_crawler.py:117
↓ 3 callersMethodgenerate
生成完整分析报告 Args: font_path: 字体路径(词云使用) title: 报告标题 Returns: 报告文件路径
源代码/爬虫进阶/11_进阶综合实战项目/analysis/report.py:379
↓ 3 callersMethodget_cookies
获取一个可用的 Cookie(负载均衡)
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/cookie_manager.py:159
↓ 3 callersMethodget_fields
(cls)
源代码/爬虫入门/11_爬虫入门实战4_高效率的爬虫实现/common.py:18
↓ 3 callersMethodget_fields
(cls)
源代码/爬虫入门/09_爬虫入门实战2_动态数据提取/common.py:18
↓ 3 callersMethodget_mobile
获取移动端 User-Agent
源代码/爬虫进阶/02_反爬虫对抗基础_请求伪装/ua_rotator.py:137
↓ 3 callersMethodget_output_path
获取输出路径
源代码/爬虫进阶/10_数据分析与可视化/chart_demo.py:451
↓ 3 callersMethodget_video_info
获取视频详情 aid 和 bvid 至少提供一个。 Args: aid: 视频 aid bvid: 视频 BV 号 Returns: BilibiliVid
源代码/爬虫进阶/11_进阶综合实战项目/client/bilibili_client.py:251
↓ 3 callersMethodhamming_distance
计算汉明距离 Args: hash1: 哈希值1 hash2: 哈希值2 Returns: 汉明距离(不同位的数量)
源代码/爬虫进阶/09_数据清洗与预处理/deduplication.py:337
↓ 3 callersMethodload
从 CSV 文件加载数据
源代码/爬虫进阶/11_进阶综合实战项目/store/backend.py:167
↓ 3 callersMethodload
从文件加载 Cookie Returns: 是否加载成功
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/bilibili_cookie.py:186
↓ 3 callersMethodlogin
执行登录 Returns: 登录结果
源代码/爬虫进阶/07_登录认证_扫码与短信登录实现/login_factory.py:45
↓ 3 callersFunctionmake_req_params_and_headers
()
源代码/爬虫入门/11_爬虫入门实战4_高效率的爬虫实现/common.py:32
↓ 3 callersMethodnavigate_to_login
导航到登录页面
源代码/爬虫进阶/07_登录认证_扫码与短信登录实现/sms_login.py:68
↓ 3 callersMethodnormalize
标准化空白字符 - 将制表符、回车等转为空格 - 合并多个空格 - 合并多个换行 - 去除首尾空白 Args: text: 输入文本 Returns:
源代码/爬虫进阶/09_数据清洗与预处理/text_cleaner.py:118
↓ 3 callersFunctionon_status_change
(status: QRCodeStatus)
源代码/爬虫进阶/07_登录认证_扫码与短信登录实现/qrcode_login.py:277
↓ 3 callersMethodparse
解析数字字符串 支持: - 逗号分隔:1,234,567 - 中文单位:1.5万、3.2亿 - 英文单位:1.5K、3.2M Args: text: 数字字符串
源代码/爬虫进阶/09_数据清洗与预处理/data_normalizer.py:163
↓ 3 callersMethodreturn_proxy
归还代理并报告使用结果 Args: proxy: 代理信息 success: 使用是否成功
源代码/爬虫进阶/03_代理IP的使用与管理/proxy_pool/pool.py:198
↓ 3 callersMethodsimilarity
计算两个字符串的相似度 相似度 = 1 - (编辑距离 / 最大长度) Args: s1: 字符串1 s2: 字符串2 Returns: 相似度 (0.0
源代码/爬虫进阶/09_数据清洗与预处理/deduplication.py:150
↓ 3 callersMethodstart
启动浏览器
源代码/爬虫进阶/11_进阶综合实战项目/core/browser.py:84
↓ 3 callersMethodto_dict
转换为 httpx 可用的字典格式
源代码/爬虫进阶/07_登录认证_扫码与短信登录实现/bilibili_qrcode_login.py:73
↓ 3 callersMethodto_dict
转换为简单字典格式(name: value)
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/cookie_manager.py:58
↓ 3 callersMethodword_frequency
统计词频 Args: texts: 文本列表 top_n: 返回 Top N Returns: (词语, 频次) 列表
源代码/爬虫进阶/10_数据分析与可视化/wordcloud_generator.py:115
↓ 2 callersMethod_parse_cookie_str
解析 Cookie 字符串 Args: cookie_str: Cookie 字符串,格式如 "name1=value1; name2=value2" Returns: List[Dict]: Pl
源代码/爬虫进阶/11_进阶综合实战项目/login/auth.py:374
↓ 2 callersMethod_random_delay
随机延迟,避免请求过快
源代码/爬虫进阶/11_进阶综合实战项目/crawler/spider.py:278
↓ 2 callersMethod_refresh_proxies
刷新代理
源代码/爬虫进阶/03_代理IP的使用与管理/proxy_pool/pool.py:125
↓ 2 callersMethodacquire
获取上下文
源代码/爬虫进阶/05_Playwright进阶_反检测与性能优化/performance_optimization.py:94
↓ 2 callersMethodbar_chart
创建交互式柱状图
源代码/爬虫进阶/10_数据分析与可视化/chart_demo.py:253
↓ 2 callersMethodbuild_page_headers
构建页面请求头 Args: referer: Referer 地址 host: Host 地址 extra_headers: 额外的请求头 Returns:
源代码/爬虫进阶/02_反爬虫对抗基础_请求伪装/headers_builder.py:59
↓ 2 callersMethodcheck
检测单个代理是否可用 Args: proxy: 代理信息 Returns: 代理是否可用
源代码/爬虫进阶/03_代理IP的使用与管理/proxy_pool/checker.py:45
↓ 2 callersMethodcheck_batch
批量检测代理 Args: proxies: 代理列表 concurrency: 并发数 Returns: 可用的代理列表
源代码/爬虫进阶/03_代理IP的使用与管理/proxy_pool/checker.py:102
↓ 2 callersMethodcheck_expiry
检查 Cookie 是否过期 Args: cookies: Playwright 格式的 Cookie 列表 Returns: (是否全部有效, 已过期的 Cookie 列表)
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/login_state_checker.py:218
↓ 2 callersMethodcheck_login_state
检查登录状态 通过检查 Cookie 中是否包含关键字段来判断是否已登录。 关键字段:SESSDATA、DedeUserID Returns: bool: 是否已登录
源代码/爬虫进阶/11_进阶综合实战项目/login/auth.py:246
↓ 2 callersFunctioncheck_proxy_list
批量检测代理列表 Args: proxy_list: 代理字符串列表 Returns: 可用的代理列表
源代码/爬虫进阶/03_代理IP的使用与管理/proxy_checker.py:54
↓ 2 callersMethodclean_with_bs4
使用 BeautifulSoup 清洗 HTML(推荐) Args: html: HTML 文本 Returns: 纯文本
源代码/爬虫进阶/09_数据清洗与预处理/text_cleaner.py:88
↓ 2 callersMethodclose
关闭客户端
源代码/爬虫进阶/01_工程化爬虫开发规范/refactored_crawler/client.py:58
↓ 2 callersMethodclose_all
关闭所有上下文
源代码/爬虫进阶/05_Playwright进阶_反检测与性能优化/performance_optimization.py:104
↓ 2 callersMethodcreate_content_checker
创建内容检测器 检测响应内容是否包含指定文本 Args: check_url: 检测 URL success_text: 登录成功时页面包含的文本 timeout: 超时时间
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/login_state_checker.py:185
↓ 2 callersMethodcreate_cookie_login
创建 Cookie 登录
源代码/爬虫进阶/07_登录认证_扫码与短信登录实现/login_factory.py:248
↓ 2 callersFunctioncreate_stealth_browser
创建带反检测的浏览器实例 Args: playwright: playwright 实例 headless: 是否无头模式 Returns: 配置好的浏览器实例
源代码/爬虫进阶/05_Playwright进阶_反检测与性能优化/stealth_demo.py:75
↓ 2 callersFunctioncreate_stealth_context
创建带反检测的浏览器上下文 Args: browser: 浏览器实例 stealth_js: stealth 脚本内容 Returns: 配置好的上下文
源代码/爬虫进阶/05_Playwright进阶_反检测与性能优化/stealth_demo.py:97
↓ 2 callersMethodensure_login
确保已登录 优先使用已保存的 Cookie,如果无效则使用指定方式登录 Args: login_config: 登录配置 force_login: 是否强制重新登录 Returns
源代码/爬虫进阶/07_登录认证_扫码与短信登录实现/login_factory.py:313
↓ 2 callersFunctionextract_wbi_keys_from_urls
从 wbi_img_urls 中提取 img_key 和 sub_key Args: img_url: img_url 完整地址 sub_url: sub_url 完整地址 Returns: tuple: (img_key
源代码/爬虫进阶/11_进阶综合实战项目/tools/sign.py:140
↓ 2 callersFunctionfetch_with_basic_retry
基础重试示例
源代码/爬虫进阶/01_工程化爬虫开发规范/exception_demo.py:91
↓ 2 callersMethodfrom_api_response
从 API 响应数据创建 BilibiliVideo 实例 Args: data: API 返回的视频详情数据 source_keyword: 搜索来源关键词 Returns:
源代码/爬虫进阶/11_进阶综合实战项目/models/bilibili.py:147
↓ 2 callersMethodfrom_browser_string
从浏览器复制的 Cookie 字符串创建 Args: cookie_string: 格式 "SESSDATA=xxx; DedeUserID=xxx; bili_jct=xxx" Returns:
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/bilibili_cookie.py:77
↓ 2 callersMethodfrom_search_result
从搜索结果数据创建 BilibiliVideo 实例 搜索结果的数据结构与视频详情略有不同,需要单独处理。 Args: data: API 返回的搜索结果数据 source_keyword: 搜索关
源代码/爬虫进阶/11_进阶综合实战项目/models/bilibili.py:187
↓ 2 callersMethodfull_preprocess
完整预处理流程 Args: image_bytes: 原始图片 threshold: 二值化阈值 Returns: 处理后的图片
源代码/爬虫进阶/08_验证码识别与处理/ocr_captcha.py:144
↓ 2 callersMethodgenerate_from_frequencies
从词频字典生成词云 Args: frequencies: {词语: 频次} 字典 output_path: 输出路径 Returns: 输出文件路径
源代码/爬虫进阶/10_数据分析与可视化/wordcloud_generator.py:221
↓ 2 callersFunctiongenerate_report
生成分析报告(便捷函数) Args: videos: 视频数据列表 output_dir: 输出目录 font_path: 字体路径 Returns: 报告文件路径
源代码/爬虫进阶/11_进阶综合实战项目/analysis/report.py:532
↓ 2 callersMethodget_cookies
获取 Cookie
源代码/爬虫进阶/07_登录认证_扫码与短信登录实现/sms_login.py:127
↓ 2 callersMethodget_expiry_summary
获取 Cookie 过期时间摘要 Args: cookies: Cookie 列表 Returns: 摘要信息字典
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/login_state_checker.py:280
↓ 2 callersMethodget_proxy
获取一个可用代理 使用加权随机选择,评分高的代理被选中概率更大
源代码/爬虫进阶/03_代理IP的使用与管理/proxy_pool/pool.py:170
↓ 2 callersMethodget_salt
生成混淆后的 salt 算法: 1. 将 img_key 和 sub_key 拼接 2. 按照映射表重新排列字符 3. 取前 32 位作为 salt Returns: str
源代码/爬虫进阶/11_进阶综合实战项目/tools/sign.py:76
↓ 2 callersMethodget_stats
获取统计信息
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/cookie_manager.py:211
↓ 2 callersMethodget_stats
获取统计信息 Returns: 包含各种统计指标的字典
源代码/爬虫进阶/03_代理IP的使用与管理/proxy_pool/pool.py:254
↓ 2 callersMethodinitialize
初始化上下文池
源代码/爬虫进阶/05_Playwright进阶_反检测与性能优化/performance_optimization.py:74
↓ 2 callersMethodinput_code
输入验证码
源代码/爬虫进阶/07_登录认证_扫码与短信登录实现/sms_login.py:99
↓ 2 callersMethodinput_phone
输入手机号
源代码/爬虫进阶/07_登录认证_扫码与短信登录实现/sms_login.py:73
↓ 2 callersMethodis_valid
检查核心 Cookie 是否存在
源代码/爬虫进阶/06_登录认证_Cookie与Session管理/bilibili_cookie.py:141
↓ 2 callersMethodload
从 JSON 文件加载数据
源代码/爬虫进阶/11_进阶综合实战项目/store/backend.py:94
↓ 2 callersFunctionmake_req_params_and_headers
()
源代码/爬虫入门/09_爬虫入门实战2_动态数据提取/common.py:32
next →1–100 of 724, ranked by callers