{"id":19653637,"url":"https://github.com/mazzzystar/baiducrawler","last_synced_at":"2025-10-04T03:48:39.470Z","repository":{"id":105064493,"uuid":"55835924","full_name":"mazzzystar/BaiduCrawler","owner":"mazzzystar","description":"Sample of using proxies to crawl baidu search results.","archived":false,"fork":false,"pushed_at":"2018-03-10T01:55:48.000Z","size":186,"stargazers_count":118,"open_issues_count":1,"forks_count":63,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-28T17:45:50.313Z","etag":null,"topics":["baidu","crawler","proxies","proxy"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mazzzystar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-04-09T09:21:55.000Z","updated_at":"2025-02-02T05:52:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"55b9f948-9fa8-42d4-a1c6-96e1a16a4014","html_url":"https://github.com/mazzzystar/BaiduCrawler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mazzzystar/BaiduCrawler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazzzystar%2FBaiduCrawler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazzzystar%2FBaiduCrawler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazzzystar%2FBaiduCrawler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazzzystar%2FBaiduCrawler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mazzzystar","download_url":"https://codeload.github.com/mazzzystar/BaiduCrawler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazzzystar%2FBaiduCrawler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278262440,"owners_count":25957937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"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":["baidu","crawler","proxies","proxy"],"created_at":"2024-11-11T15:14:43.947Z","updated_at":"2025-10-04T03:48:39.465Z","avatar_url":"https://github.com/mazzzystar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BaiduCrawler\n爬取百度搜索结果中c-abstract里的数据，并使用不断更换代理ip的方式绕过百度反爬虫策略，从而实现对数以10w计的词条的百度搜索结果进行连续爬取。\n\n![](https://github.com/fancoo/BaiduCrawler/blob/master/images/git.png)\n\n### 获取代理ip策略\n\n* 1. 抓取页面上全部[ip:port]对，并检测可用性（有的代理ip是连不通的）。\n* 2. 使用\"多轮检测\"策略，即每个ip要经历N轮，间隔为duration连接测试，每轮都会丢弃连接时间超过timeout的ip。N轮下来，存活的ip都是每次都在timeout范围以内连通的，从而避免了\"辉煌的15分钟\"效应。\n\n### 爬取策略\n\n有3个策略：\n   * 1. 每当出现download_error，更换一个IP\n   * 2. 每爬取200条文本，更换一个IP\n   * 3. 每爬取20,000次，更新一次IP资源池\n  \n上述参数均可手动调整。\n目前ip池的使用都是一次性的，\u003cb\u003e如果需要更多的优质ip\u003c/b\u003e，可参考我的另一个项目[Proxy](https://github.com/fancoo/Proxy),它是一个代理ip抓取测试评估存储一体化工具，也许可以帮到你。\n\n\n### TODO\n\n* 1. 对因网络原因未爬取的词进行二次爬取，直到达到用户指定的爬取率\n* 2. 对爬取速度快的优质ip增加权重，从而形成一个具有优先级的ip池\n* 3. ip评估改写成多线程\n\n### 使用\n#### 准备工作\n```bash\npip install requests\npip install lxml\npip install beautifulsoup4\n\ngit clone https://github.com/fancoo/BaiduCrawler\ncd BaiduCrawler\n```\n#### Python 2.7\n```bash\npython baidu_crawler.py\n```\n#### Python 3\n本程序仅在win版本的Python3.6测试通过。\n```bash\ncd Py3\npython baidu_crawler.py\n```\n\n\n### 2017/5/4更新\n * 原有的判断ip是否有效的网站失效，已替换。\n * 增加更多代理ip网站。\n * 提高可配置性。\n\n\n### 2017/6/13更新\n * 新增抓取的代理IP数据存到MySql中 下次先从库中读取 再从网站抓取\n\n### 2017/6/18更新\n * 修改了部分[BoBoGithub](https://github.com/BoBoGithub)提交的PR，并重构了[ip_pool.py](https://github.com/fancoo/Crawler/blob/master/ip_pool.py)的代码。\n * 目前这个版本其实只将有效ip保存到数据库，没能实现ip质量评优以及爬取的多线程，因时间精力有限，考虑未来再加入。\n\n### 2017/7/25更新\n* 增加对Python3.6的支持。\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmazzzystar%2Fbaiducrawler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmazzzystar%2Fbaiducrawler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmazzzystar%2Fbaiducrawler/lists"}