forked from xufp/Amazon-Robot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
63 lines (60 loc) · 2.18 KB
/
Main.py
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
# -*- coding: utf-8 -*-
# @Author: LC
# @Date: 2016-08-31 20:58:46
# @Last modified by: LC
# @Last Modified time: 2017-03-23 17:20:39
# @Email: [email protected]
import time
import os
from Robot import Robot
from get_proxy_and_user_information.GetProxy import is_valid
from record_product_information.VisitRecord import get_proxyips
from record_product_information.VisitRecord import delete_invalidIP
if __name__ == '__main__':
# provide the informaion of the product on Amazon, including asin and words for searching
asin = 'B074XDBCK3'
#asin = 'B002NSMFOQ'
brand = 'DREAMRY-Multifunctional-Rechargeable-Conferences-Conversation-Black'
search_words = 'digital voice recorders'
add_to_cart_probability = 0.7
#get all proxy ips from db, then test ip from each to each, delte invalid ip from db
result = get_proxyips()
if result is None:
os._exit()
index = 0
while True:
ip = result[index][0]
if ip is None:
break
if not is_valid('https://www.amazon.co.uk', ip):
delete_invalidIP(ip)
else:
print ip
robot = Robot(ip)
###############################################
# sign in and browse
###############################################
"""
robot.sign_in()
# one item
robot.search_keywords(search_words)
robot.simulate_browsing(search_words, asin, add_to_cart_probability)
# another item
# ....
"""
###############################################
# sign up
###############################################
#normal sign up
"""
user_info = robot.generate_sign_up_user(random_password=True)
robot.sign_up(user_info)
"""
# sign up
user_info = robot.generate_sign_up_user(random_password=True)
robot.sign_up(user_info)
time.sleep(5)
robot.search_keywords(search_words)
robot.simulate_browsing(brand, search_words, asin, add_to_cart_probability)
robot.exit_driver()
index += 1