Fix edge cases for evocati org
This commit is contained in:
parent
1e73c110da
commit
d2a18bf1cd
@ -2,14 +2,8 @@ from bs4 import BeautifulSoup
|
|||||||
import discord
|
import discord
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import requests
|
import requests
|
||||||
import datetime
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
# prints for debug
|
|
||||||
import pprint
|
|
||||||
|
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
|
||||||
|
|
||||||
wiki_url = "https://starcitizen.tools/"
|
wiki_url = "https://starcitizen.tools/"
|
||||||
|
|
||||||
@ -151,33 +145,32 @@ async def rsi_find(player):
|
|||||||
inline=False,
|
inline=False,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
org_div = soup.find("div", class_="main-org right-col visibility-V")
|
org_div = soup.find(
|
||||||
|
"div", class_=re.compile("main-org right-col visibility-[VH]")
|
||||||
org_div = soup.find("div", class_="main-org right-col visibility-V")
|
)
|
||||||
org_url = base_url + org_div.findNext("a")["href"]
|
org_url = base_url + org_div.find("div", class_="thumb").findNext("a")["href"]
|
||||||
|
|
||||||
org_response = requests.get(org_url).text
|
org_response = requests.get(org_url).text
|
||||||
org_soup = BeautifulSoup(org_response, "html.parser")
|
org_soup = BeautifulSoup(org_response, "html.parser")
|
||||||
|
|
||||||
org_name = (
|
org_name = (
|
||||||
org_div.find("span", string="Spectrum Identification (SID)")
|
org_soup.find("div", class_="inner").findNext("span", class_="symbol").text
|
||||||
.findNext("strong")
|
|
||||||
.text
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
org_rank = "N/A"
|
||||||
|
try:
|
||||||
org_rank = (
|
org_rank = (
|
||||||
org_div.find("span", string="Organization rank").findNext("strong").text
|
org_div.find("span", string="Organization rank").findNext("strong").text
|
||||||
)
|
)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
org_logo = (
|
org_logo = (
|
||||||
base_url
|
base_url + org_soup.find("div", class_="inner").findNext("img")["src"]
|
||||||
+ org_soup.find("div", class_="logo noshadow").findNext("img")["src"]
|
|
||||||
)
|
|
||||||
org_member_count = (
|
|
||||||
org_soup.find("div", class_="logo noshadow")
|
|
||||||
.findNext("span", class_="count")
|
|
||||||
.text
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
org_member_count = org_soup.find("span", class_="count").text
|
||||||
|
|
||||||
embed.add_field(name="-------", value="", inline=False)
|
embed.add_field(name="-------", value="", inline=False)
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="Org Info",
|
name="Org Info",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user