requests-html: Pythonic HTML Parsing with JavaScript Support

This repository profile is provided by osrepos.com, an open source repository discovery platform.

requests-html: Pythonic HTML Parsing with JavaScript Support

Summary

requests-html is a Python library designed to simplify HTML parsing and web scraping. It extends the familiar Requests experience with powerful parsing capabilities, including full JavaScript support via Chromium, CSS selectors, and XPath. This makes it an ideal tool for developers needing to interact with dynamic web content.

Repository Information

Analyzed by OSRepos on July 25, 2026

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

requests-html is a modern, Pythonic library for parsing HTML and scraping websites, created by Kenneth Reitz, the author of the popular Requests library. It aims to make web scraping as intuitive as possible by integrating robust features directly into the Requests workflow. Key capabilities include full JavaScript support, CSS and XPath selectors, and asynchronous operations.

Installation

Installation is straightforward. You can install requests-html using pip:

$ pip install requests-html

If you prefer pipenv, you can use:

$ pipenv install requests-html

Note that requests-html requires Python 3.6 and above.

Examples

Basic GET Request and Link Extraction

from requests_html import HTMLSession

session = HTMLSession()
r = session.get('https://python.org/')

print("All links:", r.html.links)
print("Absolute links:", r.html.absolute_links)

Using CSS Selectors

from requests_html import HTMLSession

session = HTMLSession()
r = session.get('https://python.org/')

about_element = r.html.find('#about', first=True)
if about_element:
    print("Element text:", about_element.text)
    print("Element HTML:", about_element.html)
    print("Element attributes:", about_element.attrs)

Handling JavaScript Rendered Content

requests-html can render JavaScript content using Chromium. The first time render() is called, it will download Chromium.

from requests_html import HTMLSession

session = HTMLSession()
r = session.get('https://pythonclock.org')

# Content before rendering JavaScript
print("Before render:", r.html.search('Python 2.7 will retire in...{}Enable Guido Mode')[0])

# Render JavaScript
r.html.render()

# Content after rendering JavaScript
print("After render:", r.html.search('Python 2.7 will retire in...{}Enable Guido Mode')[0])

# Extract specific data after rendering
periods = [element.text for element in r.html.find('.countdown-period')]
amounts = [element.text for element in r.html.find('.countdown-amount')]
countdown_data = dict(zip(periods, amounts))
print("Countdown data:", countdown_data)

Asynchronous Requests

For concurrent scraping, requests-html supports asynchronous operations.

from requests_html import AsyncHTMLSession

asession = AsyncHTMLSession()

async def get_pythonorg():
    r = await asession.get('https://python.org/')
    return r

async def get_reddit():
    r = await asession.get('https://reddit.com/')
    return r

results = asession.run(get_pythonorg, get_reddit)
for result in results:
    print(result.html.url)

Why Use It

requests-html stands out by offering a comprehensive solution for web scraping. Its seamless integration with the Requests library makes it immediately familiar to Python developers. The built-in JavaScript rendering capability, powered by Chromium, is a significant advantage for modern, dynamic websites. Furthermore, the support for both CSS selectors (jQuery-style) and XPath provides flexibility in element selection, making it a powerful and versatile tool for extracting data from the web.

Links

Related repositories

Similar repositories that may be relevant next.

Grab: A Powerful Python Web Scraping Framework

Grab: A Powerful Python Web Scraping Framework

July 24, 2026

Grab is a robust Python web scraping framework designed to simplify complex data extraction tasks. It provides comprehensive tools for handling network requests, processing scraped content, and managing asynchronous operations through its powerful Spider component. Developers can leverage features like automatic cookie support, HTTP/SOCKS proxies, and XPath queries for efficient web data collection.

PythonWeb ScrapingFramework
Awesome Django: A Curated List of Essential Django Resources and Packages

Awesome Django: A Curated List of Essential Django Resources and Packages

July 24, 2026

Awesome Django is a comprehensive curated list of outstanding Django apps, projects, and resources. It focuses on mature, well-maintained packages with good documentation and active user bases. This repository serves as an invaluable guide for developers looking for high-quality tools and examples within the Django ecosystem.

DjangoAwesome ListPython
Awesome Django: A Curated List of Essential Resources for Developers

Awesome Django: A Curated List of Essential Resources for Developers

July 24, 2026

Awesome Django is a comprehensive, curated list of exceptional resources, packages, and tools for Django web development. It serves as an invaluable guide for developers looking to enhance their projects with the best the Django ecosystem has to offer. With over 11,000 stars, it's a trusted community-maintained collection.

awesomeawesome-listdjango
Awesome Flask: A Curated List of Flask Resources and Plugins

Awesome Flask: A Curated List of Flask Resources and Plugins

July 23, 2026

Awesome Flask is a comprehensive, curated list of exceptional Flask resources and plugins, designed to help developers build robust web applications. It categorizes a wide array of tools, from frameworks and authentication to database integrations and development utilities, making it an invaluable guide for anyone working with the Flask ecosystem.

FlaskPythonWeb Development

Source repository

Open the original repository on GitHub.

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️