domonic¶
A Python DOM that goes way beyond minidom¶
Domonic is a Python library for generating, parsing, traversing, and manipulating real document trees with the broader web platform in mind.
HTML, SVG, DOM, events, CSSOM, geometry, observers, animation, and web APIs
A JavaScript-like runtime surface for practical porting and scripting
CLI tools for querying pages with XPath and CSS selectors
dQuery and d3 included as demanding consumers of the DOM, not just extras
The aim is to track the actual platform rather than invent a parallel helper API:
Install¶
python3 -m pip install domonic
python3 -m pip install --upgrade domonic
Quick Example¶
from domonic.html import *
page = html(
body(
h1("Hello, World!"),
a("docs", _href="https://domonic.readthedocs.io/")
)
)
print(f"{page}")
<!DOCTYPE html>
<html>
<body>
<h1>Hello, World!</h1>
<a href="https://domonic.readthedocs.io/">docs</a>
</body>
</html>
DOM Example¶
from domonic.dom import document
from domonic.html import html
root = html()
card = document.createElement("section")
card.setAttribute("class", "card")
root.appendChild(card)
print(root.querySelectorAll(".card"))
CLI¶
Query a remote page:
domonic -x https://example.com '//title'
domonic -q https://example.com 'a.cta' --attr href --first
Query a local file:
domonic --xpath-file ./page.html '//a' --count
domonic --query-file ./page.html 'a.cta' --text
Pipe HTML in directly:
curl -s https://example.com | domonic -x '//a' --count
cat page.html | domonic -q 'a.cta' --attr href
Create a project with a chosen server:
domonic -p myproject --server fastapi
Package Guide¶
- html
- dom
- events
- animation
- styles
- javascript
- webapi
- constants
- dQuery
- d3
- svg
- JSON
- terminal
- cmd
- tween
- geom
- x3d
- CDN
- decorators
- Templates and Components
- utils
- 🚀 servers
- Running a python server to view static pages
- Serving dynamic content
- Using domonic with Cherrypy
- Using domonic with Pyramid
- Using domonic with Bottle
- Using domonic with Sanic
- Using domonic with Flask
- Using domonic with FastAPI
- Using domonic with Werkzeug
- Using domonic with Starlette
- Using domonic with Tornado
- Using domonic with Django
- Using domonic with aiohttp
- SPA’s
- Using domonic with AWS lambda
- Using domonic with Google Cloud Functions
- sitemap
- 🤖 autodocs
- domonic
- domonic.html
Atag()TemplateErroraabbraddressappletareaarticleasideaudiobbasebasefontbdibdoblockquotebodybrbuttoncanvascaptioncenterciteclosed_tagcodecolcolgroupcommandcommentcontentcreate_element()datadatalistdddel_detailsdfndialogdirdivdldoctypedtemembedfieldsetfigcaptionfigurefontfooterformframeframeseth1h2h3h4h5h6headheaderhgrouphrhtmliiframeimginputinsisindexkbdkeygenlabellegendlilinklistingmainmapmarkmenumenuitemmetametermodnavnoframesnoscriptobjectoloptgroupoptionoutputpparampictureplaintextportalpreprogressqrender()rprtrubyssampscriptsearchsectionselectslotsmallsourcespanstrikestrongstylesubsubmitsummarysuptabletbodytdtemplatetextareatfootththeadtimetitletrtrackuulvarvideowbrxmp- domonic.dom
AttrCDATASectionCaretPositionCharacterDataChildNodeCommentDOMConfigDOMExceptionDOMMatrixDOMMatrixReadOnlyDOMPointDOMPointReadOnlyDOMQuadDOMRectDOMRectListDOMRectReadOnlyDOMStringMapDOMTimeStampDOMTokenListDocumentDocumentFragmentDocumentTimelineDocumentTypeElementEntityEntityReferenceHTMLAnchorElementHTMLAreaElementHTMLAudioElementHTMLBRElementHTMLBaseElementHTMLBaseFontElementHTMLBodyElementHTMLButtonElementHTMLCanvasElementHTMLCollectionHTMLContentElementHTMLDListElementHTMLDataElementHTMLDataListElementHTMLDetailsElementHTMLDialogElementHTMLDivElementHTMLDocumentHTMLElementHTMLEmbedElementHTMLFieldSetElementHTMLFormControlsCollectionHTMLFormElementHTMLFrameSetElementHTMLHRElementHTMLHeadElementHTMLHeadingElementHTMLIFrameElementHTMLImageElementHTMLInputElementHTMLIsIndexElementHTMLKeygenElementHTMLLIElementHTMLLabelElementHTMLLegendElementHTMLLinkElementHTMLMapElementHTMLMediaElementHTMLMetaElementHTMLMeterElementHTMLModElementHTMLOListElementHTMLObjectElementHTMLOptGroupElementHTMLOptionElementHTMLOptionsCollectionHTMLOutputElementHTMLParagraphElementHTMLParamElementHTMLPictureElementHTMLPortalElementHTMLPreElementHTMLProgressElementHTMLQuoteElementHTMLScriptElementHTMLSelectElementHTMLShadowElementHTMLSlotElementHTMLSourceElementHTMLSpanElementHTMLStyleElementHTMLSummaryElementHTMLTableCaptionElementHTMLTableCellElementHTMLTableColElementHTMLTableDataCellElementHTMLTableElementHTMLTableHeaderCellElementHTMLTableRowElementHTMLTableSectionElementHTMLTemplateElementHTMLTextAreaElementHTMLTimeElementHTMLTitleElementHTMLTrackElementHTMLUListElementHTMLUnknownElementHTMLVideoElementIntersectionObserverIntersectionObserverEntryMutationObserverMutationRecordNamedNodeMapNodeNodeIteratorNodeListParentNodeProcessingInstructionRadioNodeListResizeObserverResizeObserverEntryResizeObserverSizeSelectionShadowRootStaticRangeTextTreeWalkerXMLDocumentconsoleArrayBooleanDateErrorFunctionGlobalJobMapMathNumberProgramKilledReflectScreenStringWindowWorkeras_signed()clearTimeout()decodeURI()decodeURIComponent()encodeURI()encodeURIComponent()function()parseFloat()parseInt()setTimeout()windowAnimationAnimationEffectAnimationPlaybackEventComputedEffectTimingEffectTimingKeyframeEffect- domonic.terminal
TerminalExceptionaliasaptarasaatawkbannerbasenamebashbatchbcbgbindbuiltincalcallercatcccdcflowchgrpchmodchowncksumcommcommandcompgencompletecompoptcompressconvertcowsaycpcroncrontabcsplitctagscurlcutcxrefdatedddeclaredeltadfdiffdirnamedirsdisownduechoedenableenvexexitexpandexportexprfcffmpegfgfigletfilefindfingerfoldfort77fusergccgencatgetgetconfgetoptsgitgrepgroupaddgroupdelgroupsgunzipgzipheadhistoryiconvifconfigipconfigipcrmipcsjobsjoinjqkillkillalllessletlexlinklnlocallocalelocaledefloggerlognamelogoutlplsm4mailxmakemanmapfilemesgmkdirmkfifomkfilemoremvnautilusnewgrpnicenlnmnmapnohupnpmodpasswdpastepatchpathchkpaxpingpippopdprprintfprspspushdpwdpythonqalterqdelqholdqmoveqmsgqrerunqrlsqselectqsigqstatqsubreadreadarrayreadonlyrebootrenicermrmdelrmdirrsyncsactsaysccsscpsedshshiftshoptshutdownsleepsortsourcesplitsshstringsstripsttysuspendtabstailtalktarteetesttimetimestouchtputtrtraptruetsortttytypesetulimitumaskunaliasunameuncompressunexpandungetuniqunlinkunsetuptimeuseradduserdelusersuucpuudecodeuuencodeuustatuuxvalwaitwcwgetwhatwhowhoamiwritexargsyacczcat- domonic.JSON
csv2json()csvify()flatten()parse()parse_file()stringify()table2json()tablify()- domonic.CDN
CDN_CSSCDN_IMGCDN_JS- domonic.events
AbortControllerAbortSignalAnimationEventBeforeUnloadEventClipboardEventCloseEventCompositionEventCustomEventDOMContentLoadedEventDragEventErrorEventEventEventDispatcherEventListenerEventListenerOptionsEventTargetExtendableEventFetchEventFocusEventGamePadEventHashChangeEventInputEventKeyboardEventMessageEventMouseEventPageTransitionEventPointerEventPopStateEventProgressEventPromiseRejectionEventSVGEventSecurityPolicyViolationEventStorageEventSubmitEventSyncEventTimerEventTouchEventTransitionEventTweenEventUIEventWheelEvent- domonic.style
CSSColorProfileRuleCSSConditionRuleCSSCounterStyleRuleCSSDocumentRuleCSSFontFaceRuleCSSFontFeatureValuesRuleCSSGroupingRuleCSSImportRuleCSSKeyframeRuleCSSKeyframesRuleCSSMediaRuleCSSNamespaceRuleCSSPageRuleCSSRuleCSSRuleListCSSStyleDeclarationCSSStyleRuleCSSStyleSheetCSSSupportsRuleMediaListStyleStyleSheetStyleSheetList- domonic.window
CustomElementRegistryMediaQueryListNavigatorScreenWindow- domonic.utils
Utils- domonic.decorators
as_json()called()check()deprecated()el()iife()instead()log()silence()- domonic.svg
SVGElementaltGlyphaltGlyphDefaltGlyphItemanimateanimateColoranimateMotionanimateTransformcircleclipPathcreate_element()cursordefsdescdiscardellipsefeBlendfeColorMatrixfeComponentTransferfeCompositefeConvolveMatrixfeDiffuseLightingfeDisplacementMapfeDistantLightfeDropShadowfeFloodfeFuncAfeFuncBfeFuncGfeFuncRfeGaussianBlurfeImagefeMergefeMergeNodefeMorphologyfeOffsetfePointLightfeSpecularLightingfeSpotLightfeTilefeTurbulencefilterfontforeignObjectgglyphglyphRefhatchhatchpathhkernimagelinelinearGradientmarkermaskmetadatamissing_glyphmpathpathpatternpolygonpolylineradialGradientrectsolidcolorstopsvgswitchsymboltexttextPathtitletreftspanunknownuseviewvkernTween- domonic.x3d
AnchorAppearanceArc2DArcClose2DAudioClipBackgroundBallJointBillboardBinaryGeometryBlendModeBlendedVolumeStyleBlockBoundaryEnhancementVolumeStyleBoxBufferAccessorBufferGeometryBufferViewCADAssemblyCADFaceCADLayerCADPartCartoonVolumeStyleCircle2DClipPlaneCollidableShapeCollisionCollisionCollectionCollisionSensorColorColorChaserColorDamperColorInterpolatorColorMaskModeColorRGBACommonSurfaceShaderComposedCubeMapTextureComposedShaderComposedTexture3DComposedVolumeStyleConeCoordinateCoordinateDamperCoordinateDoubleCoordinateInterpolatorCylinderCylinderSensorDepthModeDirectionalLightDishDisk2DDoubleAxisHingeJointDynamicLODEdgeEnhancementVolumeStyleElevationGridEnvironmentExtrusionFieldFloatVertexAttributeFogFontStyleGeneratedCubeMapTextureGeoCoordinateGeoElevationGridGeoLODGeoLocationGeoMetadataGeoOriginGeoPositionInterpolatorGeoTransformGeoViewpointGroupHAnimDisplacerHAnimHumanoidHAnimJointHAnimSegmentHAnimSiteImageTextureImageTexture3DImageTextureAtlasIndexedFaceSetIndexedLineSetIndexedQuadSetIndexedTriangleSetIndexedTriangleStripSetInlineIsoSurfaceVolumeDataLODLinePropertiesLineSetMPRPlaneMPRVolumeStyleMaterialMatrixTextureTransformMatrixTransformMeshMetadataBooleanMetadataDoubleMetadataFloatMetadataIntegerMetadataSetMetadataStringMotorJointMovieTextureMultiTextureMultiTextureCoordinateNavigationInfoNormalNormalInterpolatorNozzleOpacityMapVolumeStyleOrientationChaserOrientationDamperOrientationInterpolatorOrthoViewpointParamParticleSetPhysicalEnvironmentLightPhysicalMaterialPixelTexturePixelTexture3DPlanePlaneSensorPointLightPointSetPolyline2DPolypoint2DPopGeometryPopGeometryLevelPositionChaserPositionChaser2DPositionDamperPositionDamper2DPositionInterpolatorPositionInterpolator2DProjectionVolumeStylePyramidQuadSetRadarVolumeStyleRectangle2DRectangularTorusRefinementTextureRemoteSelectionGroupRenderedTextureRigidBodyRigidBodyCollectionRouteScalarChaserScalarDamperScalarInterpolatorSceneSegmentedVolumeDataShadedVolumeStyleShaderPartShapeSilhouetteEnhancementVolumeStyleSingleAxisHingeJointSliderJointSlopedCylinderSnoutSolidOfRevolutionSoundSphereSphereSegmentSphereSensorSplinePositionInterpolatorSpotLightStaticGroupStippleVolumeStyleSurfaceShaderTextureSwitchTexCoordDamper2DTextTextureTextureCoordinateTextureCoordinate3DTextureCoordinateGeneratorTexturePropertiesTextureTransformTextureTransform3DTextureTransformMatrix3DTimeSensorToneMappedVolumeStyleTorusTouchSensorTransformTriangleSetTriangleSet2DTwoSidedMaterialUniformUniversalJointViewfrustumViewpointVolumeDataWorldInfoX3DX3DAppearanceChildNodeX3DAppearanceNodeX3DBackgroundNodeX3DBinaryContainerGeometryNodeX3DBindableNodeX3DBoundedObjectX3DChaserNodeX3DChildNodeX3DColorNodeX3DComposableVolumeRenderStyleNodeX3DComposedGeometryNodeX3DCoordinateNodeX3DDamperNodeX3DDragSensorNodeX3DEnvironmentNodeX3DEnvironmentTextureNodeX3DFogNodeX3DFollowerNodeX3DFontStyleNodeX3DGeometricPropertyNodeX3DGeometryNodeX3DGroupingNodeX3DInfoNodeX3DInterpolatorNodeX3DLODNodeX3DLightNodeX3DMaterialNodeX3DMetadataObjectX3DNBodyCollidableNodeX3DNavigationInfoNodeX3DNodeX3DPlanarGeometryNodeX3DPointingDeviceSensorNodeX3DRigidJointNodeX3DSensorNodeX3DShaderNodeX3DShapeNodeX3DSoundNodeX3DSoundSourceNodeX3DSpatialGeometryNodeX3DTexture3DNodeX3DTextureCoordinateNodeX3DTextureNodeX3DTextureTransformNodeX3DTimeDependentNodeX3DTouchSensorNodeX3DTransformNodeX3DVertexAttributeNodeX3DViewpointNodeX3DVolumeDataNodeX3DVolumeRenderStyleNodeanchorappearancearc2DarcClose2DaudioClipbackgroundballJointbillboardbinaryGeometryblendModeblendedVolumeStyleblockboundaryEnhancementVolumeStyleboxbufferAccessorbufferGeometrybufferViewcADAssemblycADFacecADLayercADPartcartoonVolumeStylecircle2DclipPlanecollidableShapecollisioncollisionCollectioncollisionSensorcolorcolorChasercolorDampercolorInterpolatorcolorMaskModecolorRGBAcommonSurfaceShadercomposedCubeMapTexturecomposedShadercomposedTexture3DcomposedVolumeStyleconecoordinatecoordinateDampercoordinateDoublecoordinateInterpolatorcylindercylinderSensordepthModedirectionalLightdishdisk2DdoubleAxisHingeJointdynamicLODedgeEnhancementVolumeStyleelevationGridenvironmentextrusionfieldfloatVertexAttributefogfontStylegeneratedCubeMapTexturegeoCoordinategeoElevationGridgeoLODgeoLocationgeoMetadatageoOrigingeoPositionInterpolatorgeoTransformgeoViewpointgrouphAnimDisplacerhAnimHumanoidhAnimJointhAnimSegmenthAnimSiteimageTextureimageTexture3DimageTextureAtlasindexedFaceSetindexedLineSetindexedQuadSetindexedTriangleSetindexedTriangleStripSetinlineisoSurfaceVolumeDatalODlinePropertieslineSetmPRPlanemPRVolumeStylematerialmatrixTextureTransformmatrixTransformmeshmetadataBooleanmetadataDoublemetadataFloatmetadataIntegermetadataSetmetadataStringmotorJointmovieTexturemultiTexturemultiTextureCoordinatenavigationInfonormalnormalInterpolatornozzleopacityMapVolumeStyleorientationChaserorientationDamperorientationInterpolatororthoViewpointparamparticleSetphysicalEnvironmentLightphysicalMaterialpixelTexturepixelTexture3DplaneplaneSensorpointLightpointSetpolyline2Dpolypoint2DpopGeometrypopGeometryLevelpositionChaserpositionChaser2DpositionDamperpositionDamper2DpositionInterpolatorpositionInterpolator2DprojectionVolumeStylepyramidquadSetradarVolumeStylerectangle2DrectangularTorusrefinementTextureremoteSelectionGrouprenderedTexturerigidBodyrigidBodyCollectionroutescalarChaserscalarDamperscalarInterpolatorscenesegmentedVolumeDatashadedVolumeStyleshaderPartshapesilhouetteEnhancementVolumeStylesingleAxisHingeJointsliderJointslopedCylindersnoutsolidOfRevolutionsoundspheresphereSegmentsphereSensorsplinePositionInterpolatorspotLightstaticGroupstippleVolumeStylesurfaceShaderTextureswitchtexCoordDamper2DtexttexturetextureCoordinatetextureCoordinate3DtextureCoordinateGeneratortexturePropertiestextureTransformtextureTransform3DtextureTransformMatrix3DtimeSensortoneMappedVolumeStyletorustouchSensortransformtriangleSettriangleSet2DtwoSidedMaterialuniformuniversalJointviewfrustumviewpointvolumeDataworldInfox3DAppearanceChildNodex3DAppearanceNodex3DBackgroundNodex3DBinaryContainerGeometryNodex3DBindableNodex3DBoundedObjectx3DChaserNodex3DChildNodex3DColorNodex3DComposableVolumeRenderStyleNodex3DComposedGeometryNodex3DCoordinateNodex3DDamperNodex3DDragSensorNodex3DEnvironmentNodex3DEnvironmentTextureNodex3DFogNodex3DFollowerNodex3DFontStyleNodex3DGeometricPropertyNodex3DGeometryNodex3DGroupingNodex3DInfoNodex3DInterpolatorNodex3DLODNodex3DLightNodex3DMaterialNodex3DMetadataObjectx3DNBodyCollidableNodex3DNavigationInfoNodex3DNodex3DPlanarGeometryNodex3DPointingDeviceSensorNodex3DRigidJointNodex3DSensorNodex3DShaderNodex3DShapeNodex3DSoundNodex3DSoundSourceNodex3DSpatialGeometryNodex3DTexture3DNodex3DTextureCoordinateNodex3DTextureNodex3DTextureTransformNodex3DTimeDependentNodex3DTouchSensorNodex3DTransformNodex3DVertexAttributeNodex3DViewpointNodex3DVolumeDataNodex3DVolumeRenderStyleNodex3d- domonic.geom
matrix- domonic.sitemap
atom_linkchangefreqcreate_ns_element()geo_countrygeo_geogeo_place_nameget_sitemap()image_captionimage_geo_locationimage_imageimage_licenseimage_locimage_titlelastmodlocmobile_mobilenews_keywordsnews_newsnews_publication_datenews_stock_tickersnews_titleprioritysitemapsitemap_format()sitemap_from_urls()sitemapindexsitemapindex_from_urls()urlurlsetvideo_categoryvideo_content_locvideo_descriptionvideo_durationvideo_pricevideo_price_currencyvideo_publication_datevideo_ratingvideo_tagsvideo_thumbnail_locvideo_titlevideo_videovideo_view_countxhtml_link- domonic.webapi.url
URLURLSearchParams- domonic.webapi.fetch
- Contribute
Projects¶
Blueberry: a browser-based file OS
ezcron: a cron viewer
bombdisposer: a basic game
htmlx: a lighter DOM-focused sibling project