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 | |---:|:------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------|:--------|-------:|:-------------|