Images in a table and objects decorationΒΆ

When you describe your Header fields, you can configure some of them to contain image or color data. This is done by passing the binary_type parameter to the Field constructor, when your field type is ValueType.String

class WikiPageImages(metaclass=Header):
    display_name = 'Wiki page images'

    PageUrl = Field('Page URL', ValueType.String)
    Image = Field('Image', ValueType.String, binary_type=BinaryType.Image)  # here you mark field as image
    ImageUrl = Field('Image URL', ValueType.String)
    Alt = Field('Alt', ValueType.String)

We will create a simple task for extracting images from Wikipedia articles. For this purpose, we will use the BeatifulSoup html parser and requests library.

You can install them using this command:

pip install requests, bs4

To place an image into such field, one has to convert its bytes to Base64. You can use the base64string_from_bytes() method of the Utils class for this.


You can download this example task here

Images in table

Now, to use this images as a decoration for your object, you can call SchemaObject.set_properties() and pass a system_name of your image field as image_source argument

image_in_page = SchemaObject(Image, mapping={
        Image.URL: Header.ImageUrl,
        Image.Alt: Header.Alt

Now you can launch this task and create schema with images. If your objects also contain GeoPoint attribute, you can place this objects with images on map.

Objects with images on graph