Skip to content

Commit

Permalink
V1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
davidteather committed Sep 18, 2019
1 parent 2a360c0 commit 98768df
Showing 1 changed file with 96 additions and 85 deletions.
181 changes: 96 additions & 85 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,106 +102,117 @@ def checkDealsBeautifulSoup(self, url):
index = 0
for x in range(0, len(listings)):
try:
upvote = upvotes[upvotesIndex].text.strip().replace(
" ", "").replace("°", "").replace("\n", "")
if "Deal" in upvote or "alerts" in upvote:
upvotesIndex += 1
try:
upvote = upvotes[upvotesIndex].text.strip().replace(
" ", "").replace("°", "").replace("\n", "")
if "Deal" in upvote or "alerts" in upvote:
upvotesIndex += 1
upvote = upvotes[upvotesIndex].text.strip().replace(
" ", "").replace("°", "").replace("\n", "")

except:
upvote = 0
except:
upvote = 0


try:
price = pricing[index].text.strip().replace("£", "")
except:
price = 0
try:
url = urls[index].get('href')
except:
url = None
if price != "FREE":
try:
price = float(price.replace(",", ""))
price = pricing[index].text.strip().replace("£", "")
except:
price = 0
else:
price = 0

if min_price <= price <= max_price:
if min_upvotes <= int(upvote) <= max_upvotes:
if url != None:
if url + "\n" not in usedArray and "/deals/" in url:
# Return Message
message = url + " Satisfies your deal criteria. It is at " + \
str(upvote) + \
" degrees and costs £" + str(price)

# "Apple iPad Air 3 10.5 2019 model, 64 GB 256 GB"
# "https://www.hotukdeals.com/deals/ipad-air-2019-3293151"
# "\n**Price**: $price \n**Temperature**: $upvote"
r = requests.get(url, proxies=proxy)
soup2 = BeautifulSoup(r.text, 'html.parser')

image = soup2.find('img', attrs={'class': 'thread-image'})
try:
thumbnail = image2.get('src')
except:
thumbnail = "https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fsitechecker.pro%2Fwp-content%2Fuploads%2F2017%2F12%2F404.png&f=1&nofb=1"


try:
title = image.get('alt')
except:
title = "Error"

if title != None and thumbnail != None:
json = {
"title": title,
"url": url,
"temp": int(upvote),
"price": float(price),
"thumbnail": thumbnail
}
elif title == None and thumbnail != None:
json = {
"title": "Error",
"url": url,
"temp": int(upvote),
"price": float(price),
"thumbnail": thumbnail
}

elif title != None and thumbnail == None:
json = {
"title": title,
"url": url,
"temp": int(upvote),
"price": float(price),
"thumbnail": "https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fegyptianstreets.com%2Fwp-content%2Fuploads%2F2017%2F07%2F404.jpg&f=1&nofb=1"
}

elif title == None and thumbnail == None:
json = {
"title": "Error",
"url": url,
"temp": int(upvote),
"price": float(price),
"thumbnail": "https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fegyptianstreets.com%2Fwp-content%2Fuploads%2F2017%2F07%2F404.jpg&f=1&nofb=1"
}

returnMsgs.append(json)
usedArray.append(url)
newArray.append(url)
try:
url = urls[index].get('href')
except:
url = None
if price != "FREE":
try:
price = float(price.replace(",", ""))
except:
price = 0
else:
price = 0

if min_price <= price <= max_price:
if min_upvotes <= int(upvote) <= max_upvotes:
if url != None:
if url + "\n" not in usedArray and "/deals/" in url:
# Return Message
message = url + " Satisfies your deal criteria. It is at " + \
str(upvote) + \
" degrees and costs £" + str(price)

# "Apple iPad Air 3 10.5 2019 model, 64 GB 256 GB"
# "https://www.hotukdeals.com/deals/ipad-air-2019-3293151"
# "\n**Price**: $price \n**Temperature**: $upvote"
print('here yeah' + str(x))

if proxyvar == "True" or proxyvar == True:
r = requests.get(url, proxies=proxy)
else:
r = requests.get(url)
soup2 = BeautifulSoup(r.text, 'html.parser')



image = soup2.find('img', attrs={'class': 'thread-image'})
newPrice = float(soup2.find('span', attrs={'class': 'thread-price'}).text.strip().replace("£", ""))
try:
thumbnail = image.get('src')
except:
thumbnail = "https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fsitechecker.pro%2Fwp-content%2Fuploads%2F2017%2F12%2F404.png&f=1&nofb=1"



try:
title = image.get('alt')
except:
title = "Error"

if title != None and thumbnail != None:
json = {
"title": title,
"url": url,
"temp": int(upvote),
"price": float(newPrice),
"thumbnail": thumbnail
}
elif title == None and thumbnail != None:
json = {
"title": "Error",
"url": url,
"temp": int(upvote),
"price": float(newPrice),
"thumbnail": thumbnail
}

elif title != None and thumbnail == None:
json = {
"title": title,
"url": url,
"temp": int(upvote),
"price": float(newPrice),
"thumbnail": "https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fegyptianstreets.com%2Fwp-content%2Fuploads%2F2017%2F07%2F404.jpg&f=1&nofb=1"
}

elif title == None and thumbnail == None:
json = {
"title": "Error",
"url": url,
"temp": int(upvote),
"price": float(newPrice),
"thumbnail": "https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fegyptianstreets.com%2Fwp-content%2Fuploads%2F2017%2F07%2F404.jpg&f=1&nofb=1"
}

returnMsgs.append(json)
usedArray.append(url)
newArray.append(url)
except:
continue
upvotesIndex += 1
index += 1

# Saves new logged files
with open('data/usedLinks.txt', 'a') as fileObj:
for line in newArray:
fileObj.write(line + "\n")

# Returns stuff
return returnMsgs

Expand Down

0 comments on commit 98768df

Please sign in to comment.