Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Used html module to unescape html characters #194

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion dynamic/utility.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Required for replacing html escape characters with their corresponding ascii characters
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
import html
from termcolor import colored
import requests
from rich.console import Console
Expand Down Expand Up @@ -33,6 +35,8 @@
from webdriver_manager.firefox import GeckoDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager



console = Console()


Expand Down Expand Up @@ -183,6 +187,18 @@ def __init__(self):
self.utility = Utility()
self.playbook = Playbook()

def unescape_html_characters(self, question_title):
Fixed Show fixed Hide fixed
"""
Function to replace HTML escape characters in question's title
to their corresponding ASCII characters
For example, if the title was something like this:
'"static const" vs "#define" vs "enum"'
the HTML escape characters would be replaced with their corresponding ASCII
characters and the resulting string would be:
'"static const" vs "#define" vs "enum"'
"""
return html.unescape(question_title)

def populate_question_data(self, questions_list):
"""
Function to populate question data property
Expand All @@ -199,7 +215,7 @@ def populate_question_data(self, questions_list):
sys.exit()
json_ques_data = resp.json()
self.questions_data = [
[item["title"].replace("|", ""), item["question_id"], item["link"]]
[self.unescape_html_characters(item["title"].replace("|", "")), item["question_id"], item["link"]]
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
for item in json_ques_data["items"]
]

Expand Down