Download docgenie/generation/utils/html.py from Text-to-Document-Generation/Docgenie-API: direct link, hf CLI and curl.
- Browser
- Download file 370 Bytes
-
https://huggingface.co/spaces/Text-to-Document-Generation/Docgenie-API/resolve/main/docgenie/generation/utils/html.py
- Command line
-
hf download hf://spaces/Text-to-Document-Generation/Docgenie-API/docgenie/generation/utils/html.py
-
curl -L -o html.py https://huggingface.co/spaces/Text-to-Document-Generation/Docgenie-API/resolve/main/docgenie/generation/utils/html.py
370 Bytes
| from bs4 import Tag | |
| def get_field_text(field: Tag) -> str: | |
| """ | |
| Extract text from a BeautifulSoup Tag. | |
| Works for: | |
| - <input> elements (uses 'value' attribute) | |
| - Other tags (uses inner text) | |
| """ | |
| if field.name == "input": | |
| return field.get("value", "").strip() # type: ignore | |
| else: | |
| return field.text.strip() | |