API Reference

browser

Robotic browser

class robobrowser.browser.RoboBrowser(auth=None, parser=None, headers=None, user_agent=None, history=True)[source]

Robotic web browser. Represents HTTP requests and responses using the requests library and parsed HTML using BeautifulSoup.

back(n=1)[source]

Go back in browser history.

Parameters:n (int) – Number of pages to go back
find[source]

See BeautifulSoup::find.

find_all[source]

See BeautifulSoup::find_all.

Find a click a link by tag, pattern, and/or BeautifulSoup arguments.

Parameters:value – BeautifulSoup tag, string, or regex. If tag, follow its href; if string or regex, search parsed document for match.
forward(n=1)[source]

Go forward in browser history.

Parameters:n (int) – Number of pages to go forward
get_form(id=None, *args, **kwargs)[source]

Find form by ID, as well as standard BeautifulSoup arguments.

Parameters:id (str) – Form ID
Returns:BeautifulSoup tag if found, else None
get_forms(*args, **kwargs)[source]

Find forms by standard BeautifulSoup arguments.

Returns:List of BeautifulSoup tags

Find an anchor or button by containing text, as well as standard BeautifulSoup arguments.

Parameters:text – String or regex to be matched in link text
Returns:BeautifulSoup tag if found, else None

Find anchors or buttons by containing text, as well as standard BeautifulSoup arguments.

Parameters:text – String or regex to be matched in link text
Returns:List of BeautifulSoup tags
open(url)[source]

Open a URL.

Parameters:url (str) – URL
select[source]

See BeautifulSoup::select.

submit_form(form)[source]

Submit a form.

Parameters:form (Form) – Filled-out form object
class robobrowser.browser.RoboState(browser, response)[source]

Representation of a browser state. Wraps the browser and response, and lazily parses the response content.

parsed[source]

Lazily parse response content, using HTML parser specified by the browser.

form

HTML forms

class robobrowser.forms.form.Form(parsed)[source]

Representation of an HTML form.

serialize()[source]

Serialize each form field and collect the results in a dictionary of dictionaries. Different fields may serialize their contents to different sub-dictionaries: most serialize to data, but file inputs serialize to files. Sub-dictionary keys should correspond to parameters of requests.Request.

Return dict:Dict-of-dicts of serialized data

fields

HTML form fields

class robobrowser.forms.fields.BaseField(parsed)[source]

Abstract base class for form fields.

class robobrowser.forms.fields.FieldMeta(name, bases, dct)[source]

Multiply inherit from ValueMeta and ABCMeta; classes with this metaclass are automatically assigned a value property and can use methods fromABCMeta (e.g. abstractmethod).

mro() → list

return a type’s method resolution order

register(subclass)

Register a virtual subclass of an ABC.

class robobrowser.forms.fields.ValueMeta(name, bases, dct)[source]

Metaclass that creates a value property on class creation. Classes with this metaclass should define _get_value and optionally _set_value methods.

mro() → list

return a type’s method resolution order

Table Of Contents

Related Topics

This Page

Fork me on GitHub