This commit is contained in:
2023-03-17 22:19:04 -04:00
parent ea21f8bb69
commit b4253d58f1

View File

@@ -9,7 +9,8 @@ from bs4 import BeautifulSoup as soup
bot = commands.Bot()
async def search(txt):
resp = req.post("https://www.sci-hub.st/", data={
url = "https://www.sci-hub.st/"
resp = req.post(url, data={
'request':txt
})
@@ -18,10 +19,12 @@ async def search(txt):
if 'not found' in doc.title:
return None
ref = doc.find("div", {'id': 'citation'}).get_text()
ref = doc.find('div', {'id': 'citation'}).get_text()
pdf = doc.find('div', {'id': 'pdf'})['src']
return {
'ref': ref
'ref': ref,
'pdf': f"{url}/{pdf}"
}
@bot.event
@@ -42,7 +45,8 @@ async def summarize(
await interaction.followup.send(f"Unable to find article: {article}")
return
await interaction.followup.send(f"Article Found: \n{resp['ref']}")
await interaction.followup.send(f"""Article Found: \n{resp['ref']}
PDF loc: {resp['pdf']}""")
def main():
# TODO: Import bot token from env