Skip to main content

HTML Parsing Macro things for Humans.

Project description

https://travis-ci.org/erinxocon/requests-html-macros.svg?branch=master https://img.shields.io/pypi/v/requests-html-macros.svg?maxAge=2592000 https://img.shields.io/pypi/l/requests-html-macros.svg?maxAge=2592000

Requests-Html-Macros is a little sugar on top of an already great html parseing library Requests-Html

This library aims to help make parsing the web a bit easier than it already is with Requests-Html! Create macros that can be reused over different web sites/sessions! Could you do this by hand with requests-html, yes probably pretty simply, but I only realized that liek half way through developing this library and then was just like screw it let’s push it out anyways!

Example

from time import sleep

from requests_html_macro import Macro
from requests_html import HTMLSession

# Create a standard requests-html session
session = HTMLSession()
response = session.get('http://python.org')

# Create a macro with the response
macro = Macro(response=response)

# Create a macro that uses the parse library to search through the html
@macro.search_pattern('Python is a {} language', first=True)
def foo(data):
    print(data[0])

# Creates a macro that uses a css selector
@macro.css_selector('#about', first=True)
def foo1(data):
    print(data.text)


@macro.xpath('//a', first=True)
def foo2(data):
    print(data)

while True:
    macro.parse()
    sleep(30)
    macro.response = session.get('http://python.org')

To Install

$ pip install requests-html-macro

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

requests-html-macros-0.1.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

requests_html_macros-0.1.1-py2.py3-none-any.whl (4.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file requests-html-macros-0.1.1.tar.gz.

File metadata

File hashes

Hashes for requests-html-macros-0.1.1.tar.gz
Algorithm Hash digest
SHA256 349a57531fee52d14102ef99f28e62f561f7838da2e9f23342ea9460464f710b
MD5 2cb2702f6a235d1fadbbe7e81de88f7c
BLAKE2b-256 8fd10154f1745506f6c3782ffafbb29825c8b6d7ac1dffc6775a406e86a870c9

See more details on using hashes here.

File details

Details for the file requests_html_macros-0.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for requests_html_macros-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c9628a7eb18876c9d385616cfd7936cedd99cc46e48aec4861a9ac49a2775578
MD5 d52a265c6622cac5101721f775369a38
BLAKE2b-256 2cfab71ab1dd9cec15e0db4f68f77372a536ad0a4d1477590cf3b0bd904dbff8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page