Update auto-csv/README.md
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
|
## Code:
|
||||||
```python
|
```python
|
||||||
# %%
|
# %%
|
||||||
|
|
||||||
import os; os.system('pip install -q requests bs4 lxml pandas')
|
import os; os.system('pip install -q requests bs4 lxml pandas')
|
||||||
import requests, bs4, json, pandas as pd
|
import requests, bs4, json, pandas as pd
|
||||||
|
|
||||||
@@ -19,6 +21,7 @@ def ollama(prompt):
|
|||||||
).json()['response']
|
).json()['response']
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
|
|
||||||
url = 'https://ollama.com/library'
|
url = 'https://ollama.com/library'
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
soup = bs4.BeautifulSoup(response.text, 'lxml')
|
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)
|
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.
|
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} ''')
|
HTML to analyze: {tags} ''')
|
||||||
@@ -34,7 +38,7 @@ df = pd.DataFrame(list(json.loads(result).values())[0])
|
|||||||
df
|
df
|
||||||
```
|
```
|
||||||
|
|
||||||
# Output:
|
## Output:
|
||||||
|
|
||||||
| | name | description | size | pulls | tags | updated |
|
| | name | description | size | pulls | tags | updated |
|
||||||
|---:|:------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------|:--------|-------:|:-------------|
|
|---:|:------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------|:--------|-------:|:-------------|
|
||||||
|
|||||||
Reference in New Issue
Block a user