-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
76 lines (62 loc) · 2.57 KB
/
Copy pathmain.py
File metadata and controls
76 lines (62 loc) · 2.57 KB
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
import requests
import json
import time
print("Welcome to Gaft v1.0.0. Developed by Koky and Sully")
myName = input("What is your name? ")
myEmail = input("What is your email? ")
myMessage = input("What is your message? ")
myPhone = input("What is your phone number? ")
rentalprice = int(input("How much are you looking to pay? "))
def sendEmail(ListingID):
headers = {
'Host': 'gateway.daft.ie',
'Content-Type': 'application/json',
'Connection': 'keep-alive',
'platform': 'iOS',
'Accept': 'application/json',
'brand': 'daft',
'Accept-Language': 'en-GB,en;q=0.9',
'Accept-Encoding': 'gzip, deflate, br',
'User-Agent': 'Daft.ie/0 CFNetwork/1335.0.3 Darwin/21.6.0'
}
url = "https://gateway.daft.ie/old/v1/reply"
# data = '{"name":"name","tcAccepted":true,"email":"hello@gmail.com,"message":"agagag","adId":4001666,"phone":"085811463112"}'
data = '{"name":"' + str(myName) + '","tcAccepted":true,"email":"' + str(myEmail) + '","message":"' + str(myMessage) + '","adId":' + str(ListingID) + ',"phone":"' + str(myPhone) + '"}'
print(data)
# data = {
# "name": myName,
# "tcAccepted":"true",
# "email": myEmail,
# "message": myMessage,
# "adId":ListingID,
# "phone": myPhone,
# }
# print(data)
response = requests.post(url, headers=headers, data=data)
#jsonresp = response.json()
print(response.text)
def getListing():
headers = {
'Host': 'gateway.daft.ie',
'Content-Type': 'application/json',
'Connection': 'keep-alive',
'platform': 'iOS',
'Accept': 'application/json',
'brand': 'daft',
'Accept-Language': 'en-GB,en;q=0.9',
'Accept-Encoding': 'gzip, deflate, br',
'User-Agent': 'Daft.ie/0 CFNetwork/1335.0.3 Darwin/21.6.0'
}
url = "https://gateway.daft.ie/old/v1/listings"
data = '{"section":"residential-to-rent","geoFilter":{"storedShapeIds":["33"],"name":"location","geoSearchType":"STORED_SHAPES","mapView":false},"filters":[{"values":["published"],"name":"adState"}],"paging":{"pageSize":50},"ranges":[{"name":"rentalPrice","to":"' + str(rentalprice) + '","from":""}],"sort":"publishDateDesc"}'
# print(data)
response = requests.post(url, headers=headers, data=data)
jsonresp = response.json()
listings = jsonresp['listings']
for x in listings:
ListingID = x['listing']['id']
# print('Listing ID:' + ' ' + str(x['listing']['id']) + ' Price: ' + x['listing']['price'])
sendEmail(ListingID)
time.sleep(10)
# TODO: Add method to print number of beds and bathrooms
getListing()