All Projects → MechanicalSoup → Mechanicalsoup

MechanicalSoup / Mechanicalsoup

Licence: mit
A Python library for automating interaction with websites.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Mechanicalsoup

Languagepod101 Scraper
Python scraper for Language Pods such as Japanesepod101.com 👹 🗾 🍣 Compatible with Japanese, Chinese, French, German, Italian, Korean, Portuguese, Russian, Spanish and many more! ✨
Stars: ✭ 104 (-97.31%)
Mutual labels:  requests, beautifulsoup
SD-streams
Anime streaming without ads using Beautifulsoup and requests Python
Stars: ✭ 18 (-99.53%)
Mutual labels:  requests, beautifulsoup
Decryptlogin
APIs for loginning some websites by using requests.
Stars: ✭ 1,861 (-51.83%)
Mutual labels:  requests, pypi
Gsoc Organisation Scraper
Scrape GSoC organisations using a single script.
Stars: ✭ 121 (-96.87%)
Mutual labels:  requests, beautifulsoup
cp-tool
cp-tool is an auto generator for solved problems at different online judges.
Stars: ✭ 24 (-99.38%)
Mutual labels:  pypi, requests
Pitchfork
🎶 Unofficial python API for pitchfork.com reviews.
Stars: ✭ 67 (-98.27%)
Mutual labels:  requests, beautifulsoup
Requests Html
Pythonic HTML Parsing for Humans™
Stars: ✭ 12,268 (+217.58%)
Mutual labels:  requests, beautifulsoup
Easy Scraping Tutorial
Simple but useful Python web scraping tutorial code.
Stars: ✭ 583 (-84.91%)
Mutual labels:  requests, beautifulsoup
SJS DROPS
Script using requests module to register accounts to Slam Jam Socialism raffles.
Stars: ✭ 21 (-99.46%)
Mutual labels:  requests, beautifulsoup
feupy
The sigarra scraping library no one asked for
Stars: ✭ 13 (-99.66%)
Mutual labels:  pypi, requests
Tieba-Birthday-Spider
百度贴吧生日爬虫,可抓取贴吧内吧友生日,并且在对应日期自动发送祝福
Stars: ✭ 28 (-99.28%)
Mutual labels:  requests, beautifulsoup
tiktok-downloader
Tiktok Downloader/Scraper using requests & bs4
Stars: ✭ 47 (-98.78%)
Mutual labels:  requests, beautifulsoup
ProxyGrab
Asynchronous Library made using Python and aiohttp to get proxies from multiple services!
Stars: ✭ 17 (-99.56%)
Mutual labels:  pypi, requests
Turkce Python Kaynaklari
Türkçe olarak hazırlanmış Python programlama dili ile ilgili içeriklerin derlendiği sayfa.
Stars: ✭ 295 (-92.36%)
Mutual labels:  requests, beautifulsoup
Jsbsim
An open source flight dynamics & control software library
Stars: ✭ 315 (-91.85%)
Mutual labels:  pypi
Pip Upgrader
An interactive pip requirements upgrader. It also updates the version in your requirements.txt file.
Stars: ✭ 340 (-91.2%)
Mutual labels:  pypi
Gh Action Pypi Publish
GitHub Action, for publishing distribution files to PyPI
Stars: ✭ 317 (-91.79%)
Mutual labels:  pypi
Confused
Tool to check for dependency confusion vulnerabilities in multiple package management systems
Stars: ✭ 314 (-91.87%)
Mutual labels:  pypi
Pytg
Python package that wraps around Telegram messenger CLI. Send and receive messages, and more.
Stars: ✭ 365 (-90.55%)
Mutual labels:  pypi
Webspider
在线地址: http://119.23.223.90:8000
Stars: ✭ 340 (-91.2%)
Mutual labels:  requests

MechanicalSoup. A Python library for automating website interaction.

Home page

https://mechanicalsoup.readthedocs.io/

Overview

A Python library for automating interaction with websites. MechanicalSoup automatically stores and sends cookies, follows redirects, and can follow links and submit forms. It doesn't do JavaScript.

MechanicalSoup was created by M Hickford, who was a fond user of the Mechanize library. Unfortunately, Mechanize was incompatible with Python 3 until 2019 and its development stalled for several years. MechanicalSoup provides a similar API, built on Python giants Requests (for HTTP sessions) and BeautifulSoup (for document navigation). Since 2017 it is a project actively maintained by a small team including @hemberger and @moy.

Gitter Chat

Installation

Latest Version Supported Versions

PyPy3 is also supported (and tested against).

Download and install the latest released version from PyPI:

pip install MechanicalSoup

Download and install the development version from GitHub:

pip install git+https://github.com/MechanicalSoup/MechanicalSoup

Installing from source (installs the version in the current working directory):

python setup.py install

(In all cases, add --user to the install command to install in the current user's home directory.)

Documentation

The full documentation is available on https://mechanicalsoup.readthedocs.io/. You may want to jump directly to the automatically generated API documentation.

Example

From examples/expl_qwant.py, code to get the results from a Qwant search:

"""Example usage of MechanicalSoup to get the results from the Qwant
search engine.
"""

import re
import mechanicalsoup
import html
import urllib.parse

# Connect to duckduckgo
browser = mechanicalsoup.StatefulBrowser(user_agent='MechanicalSoup')
browser.open("https://lite.qwant.com/")

# Fill-in the search form
browser.select_form('#search-form')
browser["q"] = "MechanicalSoup"
browser.submit_selected()

# Display the results
for link in browser.page.select('.result a'):
    # Qwant shows redirection links, not the actual URL, so extract
    # the actual URL from the redirect link:
    href = link.attrs['href']
    m = re.match(r"^/redirect/[^/]*/(.*)$", href)
    if m:
        href = urllib.parse.unquote(m.group(1))
    print(link.text, '->', href)

More examples are available in examples/.

For an example with a more complex form (checkboxes, radio buttons and textareas), read tests/test_browser.py and tests/test_form.py.

Development

Build Status Coverage Status Requirements Status Documentation Status CII Best Practices LGTM Alerts LGTM Grade

Instructions for building, testing and contributing to MechanicalSoup: see CONTRIBUTING.rst.

Common problems

Read the FAQ.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].