An API to parse Tibia.com content into object oriented data.
No fetching is done by this module, you must provide the html content.
Features:
- Converts data into well-structured Python objects.
- Type consistent attributes.
- All objects can be converted to JSON strings.
- Can be used with any networking library.
- Support for characters, guilds, houses and worlds.
Install and update using pip
pip install tibia.py
Installing the latest version form GitHub
pip install git+https://github.com/Galarzaa90/tibia.py.git -U
In order to use this library, you need to use an external library (requests, aiohttp) to fetch content from the website.
import tibiapy
# Asynchronously
import aiohttp
async def get_character(name):
url = tibiapy.Character.get_url(name)
async with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
content = await resp.text()
character = tibiapy.Character.from_content(content)
return character
# Synchronously
import requests
def get_character_sync(name):
url = tibiapy.Character.get_url(name)
r = requests.get(url)
content = r.text()
character = tibiapy.Character.from_content(content)
return character