小编Flo*_*ian的帖子

如何将包含从网站解析的多个链接的嵌入消息发送到 Webhook?

我希望我的嵌入消息看起来像这样,但我的只返回一个链接。

在此处输入图片说明

这是我的代码:

import requests
from bs4 import BeautifulSoup
from discord_webhook import DiscordWebhook, DiscordEmbed

url = 'https://www.solebox.com/Footwear/Basketball/Lebron-X-JE-Icon-QS-variant.html'
headers = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36'}
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.content, "lxml")
for tag in soup.find_all('a', class_="selectSize"):
    #There's multiple 'id' resulting in more than one link
    aid = tag.get('id')
    #There's also multiple sizes
    size = tag.get('data-size-us')
    #These are the links that need to be shown in the embed message
    product_links = "https://www.solebox.com/{0}".format(aid) …
Run Code Online (Sandbox Code Playgroud)

python beautifulsoup webhooks discord discord.py

6
推荐指数
1
解决办法
990
查看次数

标签 统计

beautifulsoup ×1

discord ×1

discord.py ×1

python ×1

webhooks ×1