Skip to content
Closed
Changes from all 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
13 changes: 8 additions & 5 deletions horoscope/horoscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ async def _horoscope(self, ctx, *, sign: str):
"chinese": "http://www.horoscope.com/us/horoscopes/chinese/horoscope-chinese-daily-today.aspx?sign=",
}
regex = [
r"<strong( class=\"date\"|)>([^`]*?)<\/strong> - ([^`]*?)\n",
r"<\/strong> - ([^`]*?)\n",
r"\w+\s\d+,\s\d+",
]
try:
horos = sign.split(", ")
Expand All @@ -106,8 +107,9 @@ async def _horoscope(self, ctx, *, sign: str):
async with self.session.get(uir, headers=option) as resp:
test = str(await resp.text('ISO-8859-1'))
msg = re.findall(regex[0], test)[0]
msg_content = msg[2].replace("</p>", "")
msg = msg_content + " - " + msg[1]
date = re.findall(regex[1], test)[0]
msg_content = msg.replace("</p>", "")
msg = msg_content + " - " + date
await ctx.send(
"Today's chinese horoscope for the one"
" born in the year of the {} is:\n".format(sign) + box(msg)
Expand All @@ -128,8 +130,9 @@ async def _horoscope(self, ctx, *, sign: str):
async with self.session.get(uir, headers=option) as resp:
test = str(await resp.text('ISO-8859-1'))
msg = re.findall(regex[0], test)[0]
msg_content = msg[2].replace("</p>", "")
msg = msg_content + " - " + msg[1]
date = re.findall(regex[1], test)[0]
msg_content = msg.replace("</p>", "")
msg = msg_content + " - " + date
if style == "love":
await ctx.send(
"Today's love horoscope for **{}** is:\n".format(sign) + box(msg)
Expand Down