More Examples
There's a collection of examples for markupever library.
Warning
This documentation is incomplete. Documenting everything take a while.
Using markupever alongside HTTPX
How to use markupever alongside httpx
library.
import markupever
import httpx
# Create a Client instance
with httpx.Client() as client:
# Stream a GET request to google
with client.stream(
"GET",
"https://www.example.com/",
) as stream:
# Parse the result using markupever
parser = markupever.Parser(markupever.HtmlOptions())
for content in stream.iter_bytes():
parser.process(content)
dom = parser.finish().into_dom()
Using markupever alongside Requests
How to use markupever alongside requests
library.
Using markupever alongside AIOHttp
How to use markupever alongside aiohttp
library.
Using markupever alongside PycURL
How to use markupever alongside PycURL
library.
import pycurl
import certifi
from io import BytesIO
# Create a PycURL instance
c = pycurl.Curl()
# Define Options ...
c.setopt(c.URL, 'https://www.google.com/')
c.setopt(c.CAINFO, certifi.where())
# Setup markupever to recieve response
parser = markupever.Parser()
c.setopt(c.WRITEDATA, parser)
# Send Request
c.perform()
# Close Connection
c.close()
# Use the parsed DOM
dom = parser.finish().into_dom()