From f6c0e237676c96d0c1181659d35fc370e229b274 Mon Sep 17 00:00:00 2001 From: jay817 Date: Sun, 22 Sep 2024 04:17:02 -0400 Subject: [PATCH] Update auto-csv/README.md --- auto-csv/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/auto-csv/README.md b/auto-csv/README.md index ce3b22e..4a880c5 100644 --- a/auto-csv/README.md +++ b/auto-csv/README.md @@ -1,5 +1,7 @@ +## Code: ```python # %% + import os; os.system('pip install -q requests bs4 lxml pandas') import requests, bs4, json, pandas as pd @@ -19,6 +21,7 @@ def ollama(prompt): ).json()['response'] # %% + url = 'https://ollama.com/library' response = requests.get(url) soup = bs4.BeautifulSoup(response.text, 'lxml') @@ -26,6 +29,7 @@ tags = ''.join(str(tag.prettify()) for tag in soup.find_all('li', class_='flex') print(tags) # %% + result = ollama(f''' Parse the following HTML snippet and extract the information into a JSON format. Output only the JSON data, without any additional text, explanation, or formatting. HTML to analyze: {tags} ''') @@ -34,7 +38,7 @@ df = pd.DataFrame(list(json.loads(result).values())[0]) df ``` -# Output: +## Output: | | name | description | size | pulls | tags | updated | |---:|:------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------|:--------|-------:|:-------------|