{"id":16868870,"url":"https://github.com/bennythink/pyweathercn","last_synced_at":"2025-07-04T07:32:53.396Z","repository":{"id":57458425,"uuid":"134544823","full_name":"BennyThink/pyweathercn","owner":"BennyThink","description":"A library for weather forecast!","archived":false,"fork":false,"pushed_at":"2024-02-24T18:41:14.000Z","size":128,"stargazers_count":20,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-01T19:57:10.820Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.bennythink.com/pyweathercn.html","language":"Python","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/BennyThink.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.txt","contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2018-05-23T09:20:29.000Z","updated_at":"2024-02-24T18:41:17.000Z","dependencies_parsed_at":"2024-10-13T14:59:47.975Z","dependency_job_id":"0301243f-596e-4922-b790-aca96d47eeb4","html_url":"https://github.com/BennyThink/pyweathercn","commit_stats":{"total_commits":36,"total_committers":1,"mean_commits":36.0,"dds":0.0,"last_synced_commit":"b9c186f675634aa4ba47a914d8a736b81de728c9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BennyThink%2Fpyweathercn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BennyThink%2Fpyweathercn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BennyThink%2Fpyweathercn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BennyThink%2Fpyweathercn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BennyThink","download_url":"https://codeload.github.com/BennyThink/pyweathercn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244189829,"owners_count":20412991,"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","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":[],"created_at":"2024-10-13T14:59:46.593Z","updated_at":"2025-03-22T07:30:54.186Z","avatar_url":"https://github.com/BennyThink.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pyweathercn:\r\n============\r\n.. image:: https://travis-ci.org/BennyThink/pyweathercn.svg?branch=master\r\n    :target: https://travis-ci.org/BennyThink/pyweathercn\r\n.. image:: https://badge.fury.io/py/pyweathercn.svg\r\n    :target: https://badge.fury.io/py/pyweathercn\r\n\r\nAn weather forecast library from www.weather.com.cn\r\n\r\nInstallation\r\n------------\r\n\r\nTo install this package, simply use pip: ``$ pip3 install pyweathercn``.\r\n\r\nThere's no plan to support Python 2.\r\n\r\nExample\r\n--------\r\n\r\nPython Console example:\r\n******************************\r\n\r\n.. code:: python\r\n\r\n       \u003e\u003e\u003e import pyweathercn\r\n       \u003e\u003e\u003e pyweathercn.Weather('重庆').temp()\r\n       '重庆：20'\r\n       \u003e\u003e\u003e w = pyweathercn.Weather('北京')\r\n       \u003e\u003e\u003e w.data\r\n       {'city': '北京', 'aqi': '73', 'tip': '紫外线指数中等涂擦SPF大于15、PA+防晒护肤品。穿衣指数较舒适建议穿薄外套或牛仔裤等服装。', 'temp': '11', 'forecast': [{'date': '17日（今天）', 'type': '晴', 'temp': '4℃', 'wind': '无持续风向 \u003c3级'}, {'date': '18日（明天）', 'type': '晴', 'temp': '18℃/5℃', 'wind': '南风 \u003c3级'}, {'date': '19日（后天）', 'type': '多云', 'temp': '18℃/6℃', 'wind': '西南风 \u003c3级'}, {'date': '20日（周六）', 'type': '多云', 'temp': '18℃/7℃', 'wind': '南风 \u003c3级'}, {'date': '21日（周日）', 'type': '多云', 'temp': '18℃/8℃', 'wind': '南风 \u003c3级'}, {'date': '22日（周一）', 'type': '多云转晴', 'temp': '19℃/7℃', 'wind': '南风 \u003c3级'}, {'date': '23日（周二）', 'type': '晴', 'temp': '19℃/5℃', 'wind': '西风 \u003c3级'}]}\r\n       \u003e\u003e\u003e w.today()\r\n       '北京：23日（今天）晴15℃西南风 3-4级'\r\n       \u003e\u003e\u003e w.tomorrow(True)\r\n       {'date': '24日（明天）', 'type': '晴', 'temp': '31℃/17℃', 'wind': '南风 3-4级'}\r\n       \u003e\u003e\u003e w.tip()\r\n       '北京温馨提示：紫外线指数很强涂擦SPF20以上，PA++护肤品，避强光。穿衣指数热适合穿T恤、短薄外套等夏季服装。'\r\n       \u003e\u003e\u003e w.forecast(False,5)\r\n       '北京：28日（周一）多云25℃/15℃东北风 \u003c3级'\r\n\r\nRun as a server:\r\n******************************\r\nIn order for better performance, please install Redis.\r\n\r\n.. code:: python\r\n\r\n       import pyweathercn\r\n       # running on http://127.0.0.1:8888\r\n       pyweathercn.server(host='127.0.0.1')\r\n       # running on http://0.0.0.0:3333\r\n       pyweathercn.server(3333)\r\n       # support ssl: https://www.example.com:8888\r\n       # if you fail to listen on www.example.com, you may try 0.0.0.0 instead.\r\n       pyweathercn.server('8888', 'www.example.com', ssl_options={\r\n           \"certfile\": \"fullchain.pem\",\r\n           \"keyfile\": \"privkey.pem\"})\r\n\r\nTo access REST API, you may try GET parameter, POST form-data/url-encoded form-data and POST JSON.\r\n\r\nMandatory parameter is city, optional parameter is day.\r\n\r\nGET: ``http://127.0.0.1:8888/weather?city=上海\u0026day=2``\r\n\r\nPOST:``http://127.0.0.1:8888/weather`` with form/json key-value:{\"city\",\"深圳\"}\r\n\r\n\r\nRun as a server(with API authentication):\r\n*********************************************\r\n\r\n.. code:: python\r\n\r\n       import pyweathercn\r\n       # running on http://0.0.0.0:3333\r\n       pyweathercn.server(auth='/path/to/database.sqlite')\r\n\r\nPlease refer to ``sample.sqlite`` for database format. In this sample:\r\n\r\n* times: total times for access this API\r\n* restrict: set to 0 avoid time limit\r\n* key: no more than 32 characters.\r\n\r\nYou only need to add a parameter called ``key`` for your request.\r\n\r\nAbout cURL\r\n----------\r\nIf you're using cURL on Windows(such as ``git bash``, ``MinGW``), you may receive an HTTP 400.\r\n\r\nThis is because cURL will try to encode query parameters by GBK instead of UTF-8.\r\nThis might be an implementation bug on Windows, I'm looking on it.\r\n\r\nFor now the best thing you should do is use url-encode for all your city name.\r\n\r\nTODO\r\n-----\r\n- add server deployment: systemd and docker\r\n- cURL compatibility\r\n\r\nDesign\r\n-------\r\n`RESETful API Specification \u003chttps://github.com/godruoyi/restful-api-specification\u003e`_\r\n\r\nLicense\r\n-------\r\nMIT\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbennythink%2Fpyweathercn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbennythink%2Fpyweathercn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbennythink%2Fpyweathercn/lists"}