Adventurelib gaming engine with Django
Can one use the adventurelib gaming engine with a Django application? I’d like to create a text based interactive fiction game.
The one roadblock I foresee arises from the stateless nature of the web. You will either have to (1) save the game state after each request & reload it for the next request, or (2) have each game running in a separate persistent process or container, or (3) some combination of those things.
To judge by the docs, the interactive command line interface is pretty "baked into" Adventurelib, which points to solution 2 — running it as a separate program. It is open source, though, so perhaps you can figure out a way to interface with it directly in your Django app.
Youtube Link: https://youtu.be/t-luXFgD5Gk
Objective: To scrape a List of American films of 2022
from urllib.request import urlopen
from urllib.error import HTTPError
from urllib.error import URLError
from bs4 import BeautifulSoup
URL = "https://en.wikipedia.org/wiki/List_of_American_films_of_2022"
def crawl(url):
try:
html = urlopen(URL)
soup = BeautifulSoup(html.read(), 'html.parser')
return soup
except HTTPError as e:
print(e)
except URLError as e:
print('The server could not be found!')
else:
print('It Worked!')
soup = crawl(URL)
tables = soup.find_all('table',{"class":"wikitable"})
# Extracting Highest-grossing films of 2022
hg_table = tables[0]
rows = hg_table.find_all('tr')
header = [h.text.strip() for h in rows[0].find_all('th')]
highest_grosser_datas=[]
for r in rows[1:]:
data = {}
rank = r.find('th').text.strip()
data[header[0]] = rank
for i,c in enumerate(r.find_all("td")):
data[header[i+1]] = c.text.strip()
print(data)
highest_grosser_datas.append(data)
------------------------------------------------------------------------------
{'Rank': '1', 'Title': 'Top Gun: Maverick*', 'Distributor': 'Paramount', 'Domestic Gross': '$716,351,712'}
{'Rank': '2', 'Title': 'Doctor Strange in the Multiverse of Madness', 'Distributor': 'Disney', 'Domestic Gross': '$411,331,607'}
{'Rank': '3', 'Title': 'Jurassic World Dominion', 'Distributor': 'Universal', 'Domestic Gross': '$376,009,080'}
{'Rank': '4', 'Title': 'The Batman', 'Distributor': 'Warner Bros.', 'Domestic Gross': '$369,345,583'}
About Community
Similar to this post
r/TheSilphRoad
Adventure Sync Widget now available on iOS!94%52Jan 31r/TheSilphRoad
Adventure Sync on iOS - does it count steps from Apple...63%1211/2/2018r/TheWeeknd
Adventure Time x BBTM by ME98%3Mar 27r/BottledTheApp
adventure post rules (before and after photos)100%5Mar 15r/cyberpunkred
Adventure Log: Cyberpunk Red Interlude: The CabbageCorp...90%2Mar 23r/learnpython
Generator functions... WOW.94%893dr/learnpython
How do i code a game without writing for every possibility?95%244dr/learnpython
Encrypt Python .py file92%472dr/learnpython
Does anyone know of a GUI that can be used to run a...93%5221hr/learnpython
Learning OOP.93%421dr/learnpython
Give Me a Program to Code85%1116dr/learnpython
is there a better way of doing this?94%385dr/learnpython
Can you make something happen in tkinter just by hovering...94%56dr/learnpython
Automate data from an excel sheet into a Power Apps...96%142dr/learnpython
I get so lost looking at documentation92%102d