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
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
from bs4 import BeautifulSoup
from dhooks import Embed
from discord import Webhook, RequestsWebhookAdapter
from time import sleep
import requests
proxy={
'http': '51.158.68.26:8811',
'https': '51.158.68.26:8811'
}
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"
def proxy_request(link):
req = requests.get(link, proxies=proxy)
html = req.text
soup = BeautifulSoup(html, 'lxml')
items = soup.find_all("li", {"class": "collection-product"})
if(len(items)>0):
return soup
else:
return 0
def default_request(link):
req = requests.get(link)
html = req.text
soup = BeautifulSoup(html, 'lxml')
items = soup.find_all("li", {"class": "collection-product"})
if (len(items) > 0):
return soup
else:
return 0
old_items = default_request(link).find_all("li", {"class": "collection-product"})
new_items= default_request(link).find_all("li", {"class": "collection-product"})
request_no = 1
ip = 0
while(True):
if (new_items == old_items):
if(default_request(link)==0):
soup = proxy_request(link)
new_items = soup.find_all("li", {"class": "collection-product"})
r = requests.get("http://jsonip.com", proxies=proxy)
ip = r.json()['ip']
else:
soup = default_request(link)
new_items = soup.find_all("li", {"class": "collection-product"})
r = requests.get("http://jsonip.com")
ip = r.json()['ip']
if(proxy_request(link)==0):
soup = default_request(link)
new_items = soup.find_all("li", {"class": "collection-product"})
r = requests.get("http://jsonip.com")
ip = r.json()['ip']
print(len(new_items))
print(len(old_items))
print(ip)
print("nothing has changed yet")
print(request_no)
request_no+=1
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 v4 by vanchespop')
webhook.send(embed=embed)