from bs4 import BeautifulSoup from dhooks import Embed from discord im

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from bs4 import BeautifulSoup
from dhooks import Embed
from discord import Webhook, RequestsWebhookAdapter
import requests
def parser(url, wh_id, wh_token):
req = requests.get(url)
html = req.text
soup = BeautifulSoup(html, 'lxml')
items = soup.find_all("li", {"class": "collection-product"})
i=0
for item in items:
variants = soup.find_all("ul", {"class": "product-card__variants"})[i].findChildren("li")
i+=1
sizes = {}
for variant in variants:
id = variant.find("button")['data-variant']
sizes[variant.find("button").text]= "https://kith.com/cart/" + id + ":1"
keys = sizes.keys()
values = sizes.values()
output_sizes = []
for size in sizes:
output_sizes.append('[{0}]({1})'.format(size,sizes.get(size)))
print(output_sizes)
item_url = "https://kith.com" + item.find("a")['href']
request = requests.get(item_url)
item_html = request.text
item_soup = BeautifulSoup(item_html, 'lxml')
name = item_soup.find("h1", {'class':"product-single__title"}).text
photo = "https:" + item_soup.find("img")['src']
color = item_soup.find(class_="product-single__color").text
price = item_soup.find(class_="btn product-form__add-to-cart").findChildren("span")[0].text
webhook = Webhook.partial(wh_id, wh_token, adapter=RequestsWebhookAdapter())
embed = Embed()
embed.description = '[{0}]({1})\n{2}'.format(name,item_url,color)
embed.set_thumbnail(url=photo)
embed.add_field(name='ATC', value='\n'.join(output_sizes))
embed.add_field(name='Price', value=price)
embed.set_footer(text='WebHook v3 by vanchespop')
webhook.send(embed=embed)
link = "https://kith.com/collections/new-arrivals"
wh_id = "643109450718117918"
wh_token = "lFusGXHVG47TTMwzhtACAPoAOGhDIhJvPzs_wg20l2phZbVFbF0zHmlV-YvBrM8s_zmm"
parser(link,wh_id,wh_token)