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
54
55
56
57
58
59
from bs4 import BeautifulSoup
from dhooks import Embed
from discord import Webhook, RequestsWebhookAdapter
import requests
link = "https://kith.com/collections/new-arrivals"
link_new = "https://kith.com/collections/new-arrivals?page=2"
wh_id = "643109450718117918"
wh_token = "lFusGXHVG47TTMwzhtACAPoAOGhDIhJvPzs_wg20l2phZbVFbF0zHmlV-YvBrM8s_zmm"
req = requests.get(link)
html = req.text
soup = BeautifulSoup(html, 'lxml')
old_items = soup.find_all("li", {"class": "collection-product"})
new_items= soup.find_all("li", {"class": "collection-product"})
while(True):
if (new_items == old_items):
req = requests.get(link)
html = req.text
soup = BeautifulSoup(html, 'lxml')
new_items = soup.find_all("li", {"class": "collection-product"})
print("nothing has changed yet")
else:
upload_items=[]
print("new items have been loaded, processing a webhook...")
for item in new_items:
if not (item in old_items):
upload_items.append(item)
old_items = new_items
i = 0
for item in upload_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"
output_sizes = []
for size in sizes:
output_sizes.append('[{0}]({1})'.format(size, sizes.get(size)))
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)