{"id":25803544,"url":"https://github.com/lixelv/kcal-parse","last_synced_at":"2025-07-13T05:37:10.193Z","repository":{"id":201061632,"uuid":"677511572","full_name":"lixelv/kcal-parse","owner":"lixelv","description":null,"archived":false,"fork":false,"pushed_at":"2023-10-18T19:22:25.000Z","size":792,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T20:52:06.159Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/lixelv.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}},"created_at":"2023-08-11T19:04:54.000Z","updated_at":"2023-10-28T06:44:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"555ee89c-ea59-4a6a-87be-c69f9f139a0f","html_url":"https://github.com/lixelv/kcal-parse","commit_stats":null,"previous_names":["lixelv/kcal-parse"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixelv%2Fkcal-parse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixelv%2Fkcal-parse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixelv%2Fkcal-parse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixelv%2Fkcal-parse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lixelv","download_url":"https://codeload.github.com/lixelv/kcal-parse/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241041033,"owners_count":19898975,"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":"2025-02-27T17:56:19.642Z","updated_at":"2025-02-27T17:56:20.323Z","avatar_url":"https://github.com/lixelv.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"db.py:\n```py\nimport sqlite3\n\nclass DB:\n    def __init__(self, db_name):\n        self.connect = sqlite3.connect(db_name)\n        self.cursor = self.connect.cursor()\n\n    def do(self, sql, values=()) -\u003e None:\n        self.cursor.execute(sql, values)\n        self.connect.commit()\n\n    def read(self, sql, values=()) -\u003e tuple:\n        self.cursor.execute(sql, values)\n        return self.cursor.fetchall()\n\n    def add_second_name(self, values: list | tuple | set) -\u003e None:\n        self.do('INSERT INTO second_name (name, url, first_name_id) VALUES (?, ?, ?)', tuple(values))\n\n    def add_data(self, values: list | tuple | set) -\u003e None:\n        self.do(f'INSERT INTO data (product, kcal, protein, fat, carbonates, url, second_name_id) VALUES (?, ?, ?, ?, ?, ?, ?)', tuple(values))\n\n```\nmain.py:\n```py\nimport requests\nfrom bs4 import BeautifulSoup\nfrom db import DB\n\nsql = DB('db.db')\n\nl = sql.read('SELECT id, url FROM second_name')\nfor id, url in l:\n    r = requests.get(url)\n    soup = BeautifulSoup(r.content, 'html.parser')\n    soup = soup.find('table', class_='uk-table mzr-tc-group-table uk-table-hover uk-table-striped uk-table-condensed').find('tbody')\n    for i in soup.find_all('tr'):\n        j = i.find_all('td')\n        result = [j[0].get_text()[:-2]]+[float(x.get_text().split(' ')[0].replace(',', '.')) for x in j[1:]]+[f\"https://health-diet.ru{j[0].find('a').get('href')}\", id]\n        print(result)\n        sql.add_data(result)\n\n```\ntest1.py:\n```py\nfrom bs4 import BeautifulSoup\n\nhtml = \"\"\"\n\u003chtml\u003e\n    \u003cbody\u003e\n        \u003cdiv class=\"example\"\u003eЭлемент 1\u003c/div\u003e\n        \u003cdiv class=\"example\"\u003eЭлемент 2\u003c/div\u003e\n        \u003cdiv class=\"example\"\u003eЭлемент 3\u003c/div\u003e\n        \u003cdiv class=\"example\"\u003eЭлемент 4\u003c/div\u003e\n        \u003cdiv class=\"example\"\u003eЭлемент 5\u003c/div\u003e\n        \u003cdiv class=\"example\"\u003eЭлемент 6\u003c/div\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n\"\"\"\n\nsoup = BeautifulSoup(html, 'html.parser')\n\n# Находим все элементы с классом \"example\"\nelements = soup.find_all(class_=\"example\")\n\n# Получаем первый элемент\nfirst_element = elements[0]\nprint(first_element.text)  # Вывод: Элемент 1\n\n# Получаем шестой элемент\nsixth_element = elements[5]\nprint(sixth_element.text)  # Вывод: Элемент 6\n\n```\ntest2.py:\n```py\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flixelv%2Fkcal-parse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flixelv%2Fkcal-parse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flixelv%2Fkcal-parse/lists"}