Get PDF
This commit is contained in:
@@ -9,7 +9,8 @@ from bs4 import BeautifulSoup as soup
|
|||||||
bot = commands.Bot()
|
bot = commands.Bot()
|
||||||
|
|
||||||
async def search(txt):
|
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
|
'request':txt
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -18,10 +19,12 @@ async def search(txt):
|
|||||||
if 'not found' in doc.title:
|
if 'not found' in doc.title:
|
||||||
return None
|
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 {
|
return {
|
||||||
'ref': ref
|
'ref': ref,
|
||||||
|
'pdf': f"{url}/{pdf}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
@@ -42,7 +45,8 @@ async def summarize(
|
|||||||
await interaction.followup.send(f"Unable to find article: {article}")
|
await interaction.followup.send(f"Unable to find article: {article}")
|
||||||
return
|
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():
|
def main():
|
||||||
# TODO: Import bot token from env
|
# TODO: Import bot token from env
|
||||||
|
|||||||
Reference in New Issue
Block a user