| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package main
- import (
- "log"
- "net/http"
- "net/url"
- "time"
- )
- // -------------------- 配置常量 --------------------
- const (
- Concurrency = 20 // 并发页数
- MaxPage = 100 // 单专辑最大翻页
- RetryPerPage = 5 // 单页重试次数
- Timeout = 10 // 请求超时(秒)
- ImgSelector = "#gdt" // 图片入口区域选择器(用于参考,实际用正则)
- FailedRecordUrl = "failed_keys.json"
- DownloadsDir = "downloads"
- TargetsFile = "targets.txt"
- RetryPerImg = 5 // 单图重试次数
- FailedRecordImg = "failed_downloads.json"
- DownloadDir = "downloads"
- )
- // -------------------- HTTP客户端 --------------------
- func createHTTPClient(proxy string) *http.Client {
- if proxy == "" {
- return &http.Client{
- Timeout: time.Duration(Timeout) * time.Second,
- }
- }
- proxyURL, err := url.Parse(proxy)
- if err != nil {
- log.Fatalf("解析代理地址失败: %v", err)
- }
- transport := &http.Transport{
- Proxy: http.ProxyURL(proxyURL),
- }
- return &http.Client{
- Transport: transport,
- Timeout: time.Duration(Timeout) * time.Second,
- }
- }
|