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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
from bs4 import BeautifulSoup
from dhooks import Embed
from discord import Webhook, RequestsWebhookAdapter
import urllib
import requests
proxies=[
'161.202.226.194:80',
'172.245.173.103:3128',
'138.197.204.55:3128',
'157.245.207.190:8080',
'161.202.226.194:8123',
'209.90.63.108:80',
'134.209.219.234:80',
'159.203.166.41:8080',
'207.154.231.211:3128',
'162.243.107.120:3128',
'162.243.108.141:8080',
'138.68.161.14:8080',
'13.250.49.211:80',
'162.223.88.228:8080',
'18.210.69.172:3128',
'207.154.231.216:8080',
'167.71.248.252:80',
'165.227.215.62:3128',
'198.199.119.119:8080',
'165.22.54.37:8080',
'141.125.82.106:80',
'138.68.41.90:8080',
'157.230.162.226:8118',
'159.8.114.34:8123',
'134.209.219.234:80',
'167.71.248.252:80',
'47.52.76.196:80',
'159.69.133.211:8080',
'138.68.173.29:8080',
'162.243.108.161:8080',
'162.243.108.161:8080',
'149.34.3.52:8080',
'134.209.188.111:8080',
'134.209.165.200:1080',
'138.68.173.29:3128',
'198.199.119.119:3128',
'54.208.83.109:80',
'99.126.106.177:80',
'138.197.157.60:3128',
'167.71.33.215:3128',
'138.68.41.90:3128',
'159.65.151.96:3128',
'138.197.157.32:3128',
'47.52.131.183:80',
'18.210.69.172:3128',
'165.227.215.62:8080',
'159.203.87.130:3128',
'161.202.226.194:25',
'157.245.52.211:8080',
'161.202.226.194:25'
]
list={
'https':''
}
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,proxies):
for proxy in proxies:
list['https']=proxy
try:
r = requests.get(link, proxies=list)
except:
proxies.remove(proxy)
print("exception occured, removed proxy ", proxy)
else:
print("current proxy is ", proxy)
html = r.text
soup = BeautifulSoup(html, 'lxml')
items = soup.find_all("li", {"class": "collection-product"})
if (len(items) > 0):
return soup
else:
proxies.remove(proxy)
print("shopify access denied, removed proxy ", proxy)
if len(proxies)==0:
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
default_result =0
proxy_result =0
while(True):
default_result = default_request(link)
proxy_result = proxy_request(link,proxies)
if (new_items == old_items):
if(default_result==0):
if (proxy_result == 0):
print("all ips have been banned")
break
soup = proxy_result
else:
soup = default_result
print("using resi")
new_items = soup.find_all("li", {"class": "collection-product"})
print(len(new_items))
print(len(old_items))
print("nothing has changed yet")
print("current request number is ",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)