Introduction¶
Prerequisites¶
Tibia.py requires Python 3.5 or higher. Dependencies are installed automatically when installing the package.
However, since it uses lxml
for parsing, on Linux you may require to install libxml on your system.
sudo apt-get install libxml2-dev libxslt-dev python-dev
Windows users are usually safe from this. For more information check out lxml installation page.
Usage¶
This library is composed of two parts, parsers and an asynchronous request client.
The asynchronous client (tibiapy.Client
) contains methods to obtain information from Tibia.com.
The parsing methods allow you to get Python objects given the html content of a page.
The main models have a get_url
/get_url_tibiadata
method that can be used to get their Tibia.com/TibiaData.com page.
With the url, the html/json content can be fetched and then passed to their from_content
/from_tibiadata
methods.
This allows you to use any networking module to obtain the data, and use the library to parse it.
import requests
import tibiapy
# Fetching a character using requests instead of aiohttp
def get_character(name):
url = tibiapy.Character.get_url(name)
r = requests.get(url)
content = r.text
character = tibiapy.Character.from_content(content)
return character