Reputation: 25
i'm new to python. Trying to do some webscraping(get a url, pretty simple), my function works. But when i tried to use the function with discord.py it returns a "27%" at the end of the url.
url is "'https://readms.net'"
import requests
from bs4 import BeautifulSoup
def mangareader():
url = ""
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
links = []
for link in soup.find_all('a'):
links.append(link.get('href'))
usefulmangas = []
for i in links:
if "/haikyuu/" in i:
usefulmangas.append(i)
elif "/my_hero_academia/" in i:
usefulmangas.append(i)
haikyuulink = url + usefulmangas[0]
bokunoherolink = url + usefulmangas[1]
return haikyuulink, bokunoherolink
discord.py
import discord
from teste import mangareader
TOKEN = ''
client = discord.Client()
@client.event
async def on_message(message):
# we do not want the bot to reply to itself
if message.author == client.user:
return
if message.content.startswith('!manga'):
await message.channel.send(f"{mangareader()}")
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
client.run(TOKEN)
Upvotes: 2
Views: 910