Skip to content

Commit 56a8d1f

Browse files
committed
Refactoring. html_parsing/ollama_com/
1 parent c9f15ca commit 56a8d1f

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎html_parsing/ollama_com/common.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
__author__ = "ipetrash"
5+
6+
7+
from pathlib import Path
8+
import requests
9+
10+
11+
DIR: Path = Path(__file__).resolve().parent
12+
13+
DIR_DUMPS: Path = DIR / "dumps"
14+
DIR_DUMPS.mkdir(parents=True, exist_ok=True)
15+
16+
session = requests.Session()

‎html_parsing/ollama_com/dump_models.py‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
from typing import Self
1313
from urllib.parse import urljoin
1414

15-
import requests
1615
from bs4 import BeautifulSoup, Tag
1716

17+
from common import DIR_DUMPS, session
1818

1919
FILE_NAME: Path = Path(__file__).resolve()
20-
DIR: Path = FILE_NAME.parent
2120

22-
PATH_DUMP: Path = DIR / f"{FILE_NAME.name}.jsonl"
21+
PATH_DUMP: Path = DIR_DUMPS / f"{FILE_NAME.name}.jsonl"
2322

2423

2524
@dataclass
@@ -53,8 +52,6 @@ def parse_from(cls, item: Tag, base_url: str) -> Self:
5352
)
5453

5554

56-
session = requests.Session()
57-
5855
url: str = "https://ollama.com/search"
5956
with open(PATH_DUMP, "w", encoding="UTF-8") as f:
6057
while True:
File renamed without changes.

0 commit comments

Comments
 (0)