{"id":39533850,"url":"https://github.com/zituocn/esme","last_synced_at":"2026-01-18T06:31:11.438Z","repository":{"id":57693909,"uuid":"484399063","full_name":"zituocn/esme","owner":"zituocn","description":"A golang sdk package for http requests and task queues","archived":false,"fork":false,"pushed_at":"2022-06-22T14:37:41.000Z","size":86,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-09T21:38:36.067Z","etag":null,"topics":["golang","httplib","proxy","spider"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zituocn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-22T10:55:29.000Z","updated_at":"2022-11-17T02:35:55.000Z","dependencies_parsed_at":"2022-09-26T21:00:51.656Z","dependency_job_id":null,"html_url":"https://github.com/zituocn/esme","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/zituocn/esme","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zituocn%2Fesme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zituocn%2Fesme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zituocn%2Fesme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zituocn%2Fesme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zituocn","download_url":"https://codeload.github.com/zituocn/esme/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zituocn%2Fesme/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28531997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","httplib","proxy","spider"],"created_at":"2026-01-18T06:31:10.692Z","updated_at":"2026-01-18T06:31:11.411Z","avatar_url":"https://github.com/zituocn.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esme\n\n一个go实现的多任务、多线程的网络请求SDK\n\n\n### 1. 特性\n\n* 基本的网络请求实现\n* 自定义请求参数\n* http 代理的使用\n* http 请求 debug 模式\n* http 请求的回调，包括成功回调、失败回调和重试回调\n* 支持自己设置 http.Transport\n* 内存中的任务队列实现\n* redis 任务队列实现\n\n### 2. 安装\n\n```shell\ngo get -u github.com/zituocn/esme\n```\n\n### 3. 简单的HTTP请求\n\n一个 `http get` 请求的演示代码\n\n*demo code*\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/zituocn/esme\"\n)\n\nfunc main() {\n\n\t// 请求一个天气预报的接口\n\tctx := esme.HttpGet(\"https://tenapi.cn/wether/?city=%E6%88%90%E9%83%BD\")\n\n\t// 成功的回调\n\tctx.SetSucceedFunc(func(c *esme.Context) {\n\t\tfmt.Println(\"请求成功了:\")\n\t\tfmt.Println(\"返回值 :\", c.ToString())\n\t})\n\t// 失败的回调\n\tctx.SetFailedFunc(func(c *esme.Context) {\n\t\tfmt.Println(\"请求出错了...\")\n\t\tfmt.Println(\"返回状态值 :\", c.Response.StatusCode)\n\t\tfmt.Println(\"返回值 :\", c.ToString())\n\t})\n\n\t// 设置http代理\n\tctx.SetProxy(\"http://10.10.10.10:8888\")\n\n\t// 执行请求\n\tctx.Do()\n}\n\n```\n\n*返回值*\n\n```shell\n2022/04/26 19:42:57.625 [I] context.go:120: [success] callback -\u003e main.main.func1\n请求成功了:\n返回值 : ....\n```\n\n---\n### 4. 使用任务队列\n\n使用内存任务队列的演示\n\n*demo code*\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/zituocn/esme\"\n)\n\nvar (\n\t// queue 一个内存中的任务队列\n\tqueue = esme.NewMemQueue()\n)\n\n// AddTask 添加任务\nfunc AddTask() {\n\n\tcity := []string{\"北京\", \"上海\", \"成都\", \"深圳\", \"西安\"}\n\n\theader := \u0026http.Header{}\n\theader.Set(\"User-Agent\", \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36\")\n\tfor _, item := range city {\n\t\tqueue.Add(\u0026esme.Task{\n\t\t\tUrl:    fmt.Sprintf(\"%s%s\", \"https://tenapi.cn/wether/?city=\", item),\n\t\t\tMethod: \"GET\",\n\t\t\tHeader: header,\n\t\t})\n\t}\n}\n\nfunc main() {\n\n\t// 生成任务队列\n\tAddTask()\n\n\t// 设置 任务参数\n\tjob := esme.NewJob(\"wether\", 1, queue, esme.JobOptions{\n\t\tSucceedFunc: func(ctx *esme.Context) {\n\t\t\tfmt.Println(\"成功的回调\")\n\t\t\tfmt.Println(\"返回信息 :\", ctx.ToString())\n\t\t},\n\t\tFailedFunc: func(ctx *esme.Context) {\n\t\t\tfmt.Println(\"失败的回调\")\n\t\t\tfmt.Println(\"返回状态 :\", ctx.Response.StatusCode)\n\t\t},\n\t})\n\n\t// 执行\n\tjob.Do()\n\n}\n```\n\n\n### 5. 更多文档\n\n1. [http请求的参数设置\u0026\u0026响应处理](./docs/http.md)\n2. [使用 `redis` 任务队列](./docs/job.md)\n3. [在任务队列中，使用 `代理IP池` (多个代理IP使用)](./docs/proxy.md)\n4. [和 `goquery`库的配合使用](./docs/html.md)\n5. [和 `gjson` 库的配合使用](./doc/gjson.md)\n6. [把数据存储到 `mysql` 中](./docs/db.md)\n\n### 6. 感谢\n\n* [gathertool](https://github.com/mangenotwork/gathertool)\n* [gorm](https://gorm.io/)\n* [go-redis](https://github.com/go-redis/redis)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzituocn%2Fesme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzituocn%2Fesme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzituocn%2Fesme/lists"}