Skip to content

Commit

Permalink
v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
DedInc committed Nov 1, 2022
1 parent a283a6c commit d0a1c92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 5 additions & 11 deletions problemator/problemator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@
from user_agent import generate_user_agent

categories = {}
i = 0

def searchCategories(cats):
global categories, i
global categories
for c in cats:
if 'Subcategories' in c:
searchCategories(c['Subcategories'])
else:
categories[c['LinkTo']] = {'name': c['Display'], 'id': i}
i += 1

def loadCategories():
r = get('https://www.wolframalpha.com/input/wpg/categories.jsp?load=true',
headers={'User-Agent': generate_user_agent()}).json()
searchCategories(r['Categories']['Categories'])
categories[c['LinkTo']] = {'name': c['Display'], 'id': len(categories)}


def getCategories():
Expand All @@ -39,14 +32,15 @@ def getCategoryByName(name):

def loadSession():
global API, s
loadCategories()
s = Session()
s.headers['User-Agent'] = generate_user_agent()
s.headers['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'
s.headers['Accept-Encoding'] = 'gzip, deflate, br'
s.headers['Accept-Language'] = 'ru-RU,ru;q=0.9,kk-KZ;q=0.8,kk;q=0.7,en-US;q=0.6,en;q=0.5'

API = s.get('https://www.wolframalpha.com/input/wpg/categories.jsp?load=true').json()['domain']
r = s.get('https://www.wolframalpha.com/input/wpg/categories.jsp?load=true').json()
searchCategories(r['Categories']['Categories'])
API = r['domain']


def checkProblem(problem, answer):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="problemator",
version="1.0.3",
version="1.0.4",
author="Maehdakvan",
author_email="visitanimation@google.com",
description="WolframAlpha's Unlimited AI-generated practice problems and answers API wrapper.",
Expand Down

0 comments on commit d0a1c92

Please sign in to comment.