Example #1
0
 def upload_pic(self):
     all_upload_num = 0
     sql = 'SELECT * from config where id=1'
     upload_num_res = fetch_one_sql(self.conn3, sql)
     if upload_num_res:
         all_upload_num = upload_num_res['upload_num']
     print('Start uploading images...')
     while True:
         save_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
         sql = "SELECT count(-1) as allnum from pin_upload where belong_web=%s and save_time>=%s"
         upload_num = fetch_one_sql(
             self.conn3, sql, (self.belong_web, self.current_time))['allnum']
         if upload_num < all_upload_num:
             sql = 'SELECT * from pin_upload where saved=0 and belong_web=%s order by id asc limit 1'
             result = fetch_one_sql(self.conn3, sql, self.belong_web)
             if result:
                 upload_pic_path = result['savelink']
                 upload_pic_board = result['saveboard']
                 upload_pic_id = result['Id']
                 self.driver.get(upload_pic_path)
                 time.sleep(5)
                 try:
                     self.driver.find_element_by_xpath(
                         "//input[@id='pickerSearchField']").send_keys(upload_pic_board)
                 except Exception as e:
                     print('Image save failed, element not found')
                 time.sleep(1)
                 try:
                     win32api.keybd_event(13, 0, 0, 0)
                     win32api.keybd_event(
                         13, 0, win32con.KEYEVENTF_KEYUP, 0)
                     time.sleep(5)
                 except Exception as e:
                     pass
                 if self.driver.page_source.find('Sorry! We blocked this link because it may lead to spam.') > -1:
                     print('Domain name banned!')
                     sql = 'UPDATE web_url set state=4 where url=%s'
                     commit_sql(self.conn3, sql, self.belong_web)
                     sql = 'UPDATE account set upload_done=664 where id=%s'
                     commit_sql(self.conn, sql, account_id)
                     break
                 try:
                     self.driver.find_element_by_xpath(
                         "//div[@class='mainContainer']//div[1]/div/button").click()
                     time.sleep(5)
                     sql = 'UPDATE pin_upload set saved=1, save_time=%s where id=%s'
                     commit_sql(self.conn3, sql, (save_time, upload_pic_id))
                     print('Uploading %d' % int(upload_num + 1))
                     write_txt_time()
                 except Exception as e:
                     pass
             else:
                 print('Not data...')
                 sql = 'UPDATE account set upload_done=669 where id=%s'
                 commit_sql(self.conn, sql, account_id)
                 time.sleep(3)
                 break
         else:
             break
Example #2
0
 def handle_pop_up(self):
     try:
         self.driver.find_element_by_xpath(
             "//span[text()='Female']").click()
         time.sleep(1)
     except:
         pass
     time.sleep(1)
     try:
         click_confirm = self.driver.switch_to.alert
         click_confirm.accept()
         time.sleep(1)
     except Exception as e:
         print('No popovers to process, skip...')
     time.sleep(1)
     try:
         self.driver.find_element_by_xpath(
             '//div[@class="NuxPickerFooter"]//button').click()
         print('Preference already selected')
         time.sleep(1)
     except Exception as e:
         print('No need to select preference, skip...')
     time.sleep(1)
     try:
         self.driver.find_element_by_xpath(
             '//div[@class="ReactModalPortal"]//button[@aria-label="cancel"]'
         ).click()
         print('Preference set')
         time.sleep(1)
     except Exception as e:
         print('No preference Settings, skip...')
     time.sleep(1)
     try:
         self.driver.find_element_by_xpath(
             '//div[@class="ReactModalPortal"]//button').click()
         print('Email has been confirmed')
         time.sleep(1)
     except Exception as e:
         print('No need to confirm email, skip...')
     time.sleep(1)
     try:
         self.driver.find_element_by_xpath(
             "//div[@class='NagBase']/div/div[2]/button").click()
         print('The renewal agreement has been accepted')
         time.sleep(1)
     except Exception as e:
         print('No need to accept the update protocol, skip...')
     time.sleep(1)
     try:
         self.driver.find_element_by_xpath(
             '//button[@aria-label="Hide Checklist"]').click()
     except:
         pass
     time.sleep(2)
     write_txt_time()
Example #3
0
 def follow(self):
     print('Turn on the follow function, count:', self.follow_num)
     sql = 'SELECT * from follow_url where for_config=10 limit %s'
     results = fetch_all_sql(self.conn2, sql, self.follow_num)
     if results:
         for res in results:
             web_url_id = res['Id']
             web_url = res['web_url']
             home_url = res['home_url']
             sql = 'SELECT * from follow_history where user_id=%s and follow_account=%s'
             judge_exist = fetch_one_sql(self.conn2, sql,
                                         (web_url_id, self.email))
             if judge_exist:
                 print('Already followed!')
             else:
                 try:
                     self.driver.get(home_url)
                 except:
                     pass
                 time.sleep(5)
                 try:
                     follow_state = self.driver.find_element_by_xpath(
                         '//div[@class="fixedHeader"]//div[3]//div[2]/button/div'
                     ).text
                     if follow_state == 'Follow':
                         self.driver.find_element_by_xpath(
                             '//div[@class="fixedHeader"]//div[3]//div[2]/button'
                         ).click()
                         time.sleep(1)
                 except:
                     pass
                 try:
                     follow_state = self.driver.find_element_by_xpath(
                         '//div[@class="CreatorFollowButton step0"]//div[2]/div'
                     ).text
                     if follow_state == 'Follow':
                         self.driver.find_element_by_xpath(
                             '//div[@class="CreatorFollowButton step0"]/div/div/div/div'
                         ).click()
                         time.sleep(1)
                 except:
                     pass
                 sql = 'INSERT INTO follow_history (user_id, user, user_homepage, follow_account) values (%s, %s, %s, %s)'
                 commit_sql(self.conn2, sql,
                            (web_url_id, web_url, home_url, self.email))
             write_txt_time()
Example #4
0
 def random_browsing(self, search_pattern=0, board_name='like', belong=2):
     # if search_pattern == 1:
     #     random_browsing_num = self.search_key_words_num
     #     print('Save picture number:', random_browsing_num)
     random_browsing_num = random.randint(self.browsing_pic_min_num,
                                          self.browsing_pic_max_num)
     print('Start random browsing:', random_browsing_num, 'time')
     for i in range(random_browsing_num):
         try:
             write_txt_time()
             web_pin_arr = self.driver.find_elements_by_xpath(
                 "//div[@data-grid-item='true']")
             click_num = random.randint(1, 8)
             print('Start the', i + 1, 'browsing')
             web_pin_num = 1
             for web_pin_one in web_pin_arr:
                 if web_pin_num == click_num:
                     web_pin_one.click()
                     time.sleep(5)
                     try:
                         self.close_AD_page()
                     except Exception as e:
                         if search_pattern == 1:
                             self.save_pic(board_name)
                         elif search_pattern == 0 and self.save_pic_control == 1 and (
                                 i + 1) % 2 == 0:
                             self.save_pic()
                     win32api.keybd_event(27, 0, 0, 0)
                     win32api.keybd_event(27, 0, win32con.KEYEVENTF_KEYUP,
                                          0)
                     time.sleep(3)
                     # self.driver.execute_script('window.scrollTo(1, 4000)')
                     win32api.keybd_event(35, 0, 0, 0)
                     win32api.keybd_event(35, 0, win32con.KEYEVENTF_KEYUP,
                                          0)
                     time.sleep(3)
                     break
                 else:
                     web_pin_num += 1
         except Exception as e:
             print(e)
         time.sleep(3)
     write_txt_time()
Example #5
0
 def create_board(self):
     print('Start create board')
     sql = "SELECT home_page from account where id=%s"
     result = fetch_one_sql(self.conn, sql, self.account_id)
     if result:
         home_page = result['home_page'] + 'boards/'
     sql = "SELECT board_name from board_template order by RAND() limit %s"
     results = fetch_all_sql(self.conn, sql, self.create_board_num)
     for board_echo in results:
         board_name = board_echo['board_name']
         print('Boardname', board_name)
         try:
             self.driver.get(home_page)
             time.sleep(5)
             self.driver.find_element_by_xpath(
                 '//button[@aria-label="Profile actions overflow"]').click(
                 )
             time.sleep(2)
             self.driver.find_element_by_xpath(
                 '//div[@class="fixedHeader"]//div[text()="Create board"]'
             ).click()
             time.sleep(5)
             self.driver.find_element_by_xpath(
                 '//form//input[@id="boardEditName"]').send_keys(board_name)
             time.sleep(1)
             self.driver.find_element_by_xpath(
                 '//form//button[@type="submit"]').click()
             time.sleep(2)
             sql = "UPDATE account set created_boards=created_boards+1 where id=%s"
             commit_sql(self.conn, sql, self.account_id)
             time.sleep(3)
             write_txt_time()
         except:
             pass
     self.driver.get('https://www.pinterest.com')
     time.sleep(5)
Example #6
0
 def pinterest_acotion(self):
     while True:
         if self.success_num > 4:
             os.system('shutdown -r')
             print('clear cache')
             time.sleep(9999)
         write_txt_time()
         print(self.hostname)
         self.get_account()
         if self.account_id > 0:
             self.success_num += 1
             connect_vpn(self.conn1, self.vpn)
             write_txt_time()
             options = webdriver.ChromeOptions()
             options.add_argument('disable-infobars')
             options.add_argument('user-agent="%s"' % self.agent)
             prefs = {
                 'profile.default_content_setting_values':
                 {'notifications': 2
                  }
             }
             options.add_experimental_option('prefs', prefs)
             self.driver = webdriver.Chrome(chrome_options=options)
             self.driver.maximize_window()
             login_state = login(
                 self.driver, self.email, self.pwd, self.account_id, self.cookie, self.conn)
             time.sleep(2)
             try:
                 home_button = self.driver.find_element_by_xpath(
                     '//div[@aria-label="Home"]/a/div/div/div/div').text
                 if home_button == 'Home':
                     self.login_state_flag = 'on'
             except Exception as e:
                 self.login_state_flag = 'off'
             print('State of home page:', self.login_state_flag)
             if self.login_state_flag == 'on':
                 self.handle_pop_up()
             # print(login_state)
             if login_state == 1 and self.login_state_flag == 'on':
                 sql = "UPDATE account set login_times=login_times+1 where id=%s"
             else:
                 sql = "UPDATE account set state=4, login_times=0, action_computer='-' where id=%s"
                 try:
                     error_type = self.driver.find_element_by_xpath(
                         '//form//button/span').text
                     if error_type == 'Reset your password':
                         sql = 'UPDATE account set state=9, login_times=0, action_computer="-" where id=%s'
                         print('Error code: 9')
                 except Exception as e:
                     pass
                 time.sleep(3)
                 try:
                     if self.driver.page_source.find('Your account has been suspended') > -1:
                         sql = 'UPDATE account set state=99, login_times=0, action_computer="-" where id=%s'
                         print('Error code: 99')
                 except Exception as e:
                     pass
             commit_sql(self.conn, sql, self.account_id)
             if login_state == 0 or self.login_state_flag == 'off':
                 print('Account log-in failure, will exit the browser!')
                 try:
                     self.driver.quit()
                 except:
                     pass
                 time.sleep(5)
                 continue
             else:
                 write_txt_time()
                 self.access_home_page()
                 if self.created_boards < 5:
                     self.create_board()
                 self.upload_pic()
                 print('End of account processing...')
                 self.driver.quit()
                 sql = "UPDATE account set state=1, login_times=0, action_time=%s, action_computer='-' where id=%s"
                 commit_sql(self.conn, sql,
                            (self.current_time, self.account_id))
                 write_txt_time()
                 time.sleep(10)
         else:
             print('Not data...')
             write_txt_time()
             time.sleep(10)
             print('The system will reboot in 30 minutes')
             os.system('shutdown -r -t 1800')
             time.sleep(9999)
Example #7
0
 def get_account(self):
     # self.get_account_count()
     if self.hostname == 'Vinter-Wang':
         sql = 'SELECT * from account where id=1'
         result = fetch_one_sql(self.conn, sql)
     else:
         sql = 'SELECT * from account where state=1 and action_time<%s and upload_done=666 and action_computer=%s order by action_time asc limit 1'
         result = fetch_one_sql(
             self.conn, sql, (self.current_time, self.hostname))
     if result:
         self.account_id = result["id"]
         self.email = result["email"]
         self.pwd = result["pw"]
         self.vpn = result['vpn']
         self.cookie = result['cookie']
         self.config_id = result['setting_other']
         self.created_boards = result['created_boards']
         self.agent = result['agent']
         self.belong_web = result['upload_web']
         if not self.agent:
             sql = 'SELECT * from user_agent where terminal="computer" and read_time<4 order by RAND() limit 1'
             agent_in_sql = commit_sql(self.conn2, sql)
             if agent_in_sql:
                 self.agent = agent_in_sql['user_agent']
                 agent_id = agent_in_sql['Id']
                 sql = 'UPDATE account set agent=%s where id=%s'
                 commit_sql(self.conn, sql, (self.agent, self.account_id))
                 sql = 'UPDATE user_agent set read_time=read_time+1 where id=%s'
                 commit_sql(self.conn2, sql, agent_id)
         print("Start account processing:", "ID:",
               self.account_id, "Email:", self.email)
         write_txt_time()
     else:
         sql = 'SELECT * from account where state=1 and action_time<%s and upload_done=666 and action_computer="-" order by action_time asc limit 1'
         result = fetch_one_sql(self.conn, sql, self.current_time)
         if result:
             self.account_id = result["id"]
             self.email = result["email"]
             self.pwd = result["pw"]
             self.vpn = result['vpn']
             self.cookie = result['cookie']
             self.config_id = result['setting_other']
             self.created_boards = result['created_boards']
             self.account_group = result['account_group']
             self.agent = result['agent']
             self.belong_web = result['upload_web']
             if not self.agent:
                 sql = 'SELECT * from user_agent where terminal="computer" and read_time<4 order by RAND() limit 1'
                 agent_in_sql = fetch_one_sql(self.conn2, sql)
                 if agent_in_sql:
                     self.agent = agent_in_sql['user_agent']
                     agent_id = agent_in_sql['Id']
                     sql = 'UPDATE account set agent=%s where id=%s'
                     commit_sql(self.conn, sql,
                                (self.agent, self.account_id))
                     sql = 'UPDATE user_agent set read_time=read_time+1 where id=%s'
                     commit_sql(self.conn2, sql, agent_id)
             print("Start account processing:", "ID:",
                   self.account_id, "Email:", self.email)
             sql = "UPDATE account set action_computer=%s where id=%s"
             commit_sql(self.conn, sql, (self.hostname, self.account_id))
             write_txt_time()
Example #8
0
 def save_pic_from_homepage(self):
     sql = "SELECT * from follow_url where for_config=10 and account_group=%s"
     result = fetch_one_sql(self.conn2, sql, self.account_group)
     if result:
         http_in_sql = result['web_url']
         home_url = result['home_url']
     try:
         self.driver.find_element_by_xpath(
             '//div[@aria-label="Pins from people you follow"]/a/div'
         ).click()
         time.sleep(5)
         self.driver.find_element_by_xpath(
             '//button[@aria-label="Find new people to follow"]').click()
     except:
         self.driver.find_element_by_xpath(
             '//div[@data-test-id="button-container"]/div[2]').click()
     time.sleep(5)
     all_following = self.driver.find_elements_by_xpath(
         '//div[@data-grid-item="true"]')
     for one_following in all_following:
         following_homepage = one_following.find_element_by_xpath(
             './div/div/div/a').get_attribute('href')
         if following_homepage == home_url:
             one_following.click()
             time.sleep(5)
             break
     windows = self.driver.window_handles
     self.driver.switch_to.window(windows[1])
     self.driver.execute_script('window.scrollTo(1, 500)')
     time.sleep(5)
     try:
         web_pin_arr = self.driver.find_elements_by_xpath(
             "//div[@data-grid-item='true']")
     except:
         time.sleep(3)
         web_pin_arr = self.driver.find_elements_by_xpath(
             "//div[@data-grid-item='true']")
     pin_count = 0
     for web_pin_one in web_pin_arr:
         try:
             ActionChains(
                 self.driver).move_to_element(web_pin_one).perform()
             time.sleep(3)
         except:
             pass
         try:
             web_pin = self.driver.find_element_by_xpath(
                 "//a[@class='navigateLink']//div[2]/div")
             time.sleep(2)
             web_pin_url = web_pin.text
             if web_pin_url == http_in_sql:
                 time.sleep(1)
                 specific_pin_url = web_pin_one.find_element_by_xpath(
                     './/div[@class="pinWrapper"]/div/a').get_attribute(
                         'href')
                 time.sleep(1)
                 specific_pin_pic_url = web_pin_one.find_element_by_xpath(
                     './/div[@class="pinWrapper"]//img').get_attribute(
                         'src')
                 board_name = 'dress'
                 self.save_pic(board_name=board_name,
                               belong=1,
                               specific_pin_url=specific_pin_url,
                               specific_pin_pic_url=specific_pin_pic_url)
                 time.sleep(3)
                 sql = "SELECT count(-1) as allnum from pin_history where account_id=%s and add_time>=%s"
                 pin_count = fetch_one_sql(
                     self.conn, sql,
                     (self.account_id, self.current_time))['allnum']
         except Exception as e:
             pass
         if pin_count >= int(self.pin_self_count):
             break
     write_txt_time()
Example #9
0
 def click_specific_pin(self):
     print('Start searching for our company images')
     sql = "SELECT count(-1) as allnum from pin_history where account_id=%s and add_time>=%s"
     pin_count = fetch_one_sql(
         self.conn, sql, (self.account_id, self.current_time))['allnum']
     if pin_count < int(self.pin_self_count):
         sql = "SELECT web_url from follow_url"
         results = fetch_all_sql(self.conn2, sql)
         http_in_sql_list = []
         for res in results:
             http_in_sql = res['web_url']
             http_in_sql_list.append(http_in_sql)
         sql = "SELECT * from search_words where us=1 order by RAND() limit %s"
         key_wrods = fetch_all_sql(self.conn2, sql, self.search_words_count)
         if key_wrods:
             for key_wrod in key_wrods:
                 search_key_words = key_wrod['word']
                 board_name = key_wrod['boards']
                 # belong = result['us']
                 try:
                     self.driver.find_element_by_name('q').click()
                     time.sleep(1)
                     self.driver.find_element_by_name('q').clear()
                     time.sleep(1)
                     self.driver.find_element_by_name('q').send_keys(
                         search_key_words)
                     time.sleep(1)
                     win32api.keybd_event(13, 0, 0, 0)
                     win32api.keybd_event(13, 0, win32con.KEYEVENTF_KEYUP,
                                          0)
                 except:
                     pass
                 try:
                     self.driver.find_element_by_name(
                         "searchBoxInput").click()
                     time.sleep(1)
                     self.driver.find_element_by_name(
                         "searchBoxInput").clear()
                     time.sleep(1)
                     self.driver.find_element_by_name(
                         "searchBoxInput").send_keys(search_key_words)
                     time.sleep(1)
                     win32api.keybd_event(13, 0, 0, 0)
                     win32api.keybd_event(13, 0, win32con.KEYEVENTF_KEYUP,
                                          0)
                 except:
                     pass
                 time.sleep(8)
                 for _ in range(self.scroll_num):
                     try:
                         web_pin_arr = self.driver.find_elements_by_xpath(
                             "//div[@data-grid-item='true']")
                         # print(len(web_pin_arr))
                     except:
                         time.sleep(3)
                         web_pin_arr = self.driver.find_elements_by_xpath(
                             "//div[@data-grid-item='true']")
                     for web_pin_one in web_pin_arr:
                         try:
                             ActionChains(self.driver).move_to_element(
                                 web_pin_one).perform()
                             time.sleep(3)
                             write_txt_time()
                         except:
                             pass
                         try:
                             web_pin = self.driver.find_element_by_xpath(
                                 '//a[@rel="nofollow"]//div[2]/div')
                             time.sleep(2)
                             web_pin_url = web_pin.text
                             # print(web_pin_url)
                             if web_pin_url in http_in_sql_list:
                                 time.sleep(1)
                                 specific_pin_url = web_pin_one.find_element_by_xpath(
                                     './/div[@class="pinWrapper"]/div/a'
                                 ).get_attribute('href')
                                 time.sleep(1)
                                 specific_pin_pic_url = web_pin_one.find_element_by_xpath(
                                     './/div[@class="pinWrapper"]//img'
                                 ).get_attribute('src')
                                 self.save_pic(
                                     board_name=board_name,
                                     belong=1,
                                     specific_pin_url=specific_pin_url,
                                     specific_pin_pic_url=
                                     specific_pin_pic_url)
                                 sql = "SELECT count(-1) as allnum from pin_history where account_id=%s and add_time>=%s"
                                 pin_count = fetch_one_sql(
                                     self.conn, sql,
                                     (self.account_id,
                                      self.current_time))['allnum']
                         except Exception as e:
                             # self.logs.error('This is an error message!', exc_info=True)
                             pass
                         if pin_count >= int(self.pin_self_count):
                             break
                     if pin_count >= int(self.pin_self_count):
                         break
                     else:
                         win32api.keybd_event(35, 0, 0, 0)
                         win32api.keybd_event(35, 0,
                                              win32con.KEYEVENTF_KEYUP, 0)
                         time.sleep(5)
                 if pin_count >= int(self.pin_self_count):
                     break
     else:
         print('Saved enough!')
Example #10
0
 def save_pic(self,
              board_name='like',
              belong=2,
              specific_pin_url='empty',
              specific_pin_pic_url='empty'):
     saved_flag = ''
     if specific_pin_url != 'empty':
         pin_url = specific_pin_url
         pin_pic_url = specific_pin_pic_url
     else:
         pin_url = self.driver.current_url
         time.sleep(1)
         pin_pic_url = self.driver.find_element_by_xpath(
             '//a[@class="imageLink"]//img').get_attribute('src')
     add_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
     try:
         saved_flag = self.driver.find_elements_by_xpath(
             '//div[@data-test-id="saved-info"]/div/a/span').text
     except:
         pass
     if saved_flag == 'Saved to ':
         print('The picture has been saved.')
     else:
         if belong == 2:
             sql = 'SELECT * from other_pin_history where pin_pic_url=%s and account_id=%s'
         elif belong == 1:
             sql = 'SELECT * from pin_history where pin_pic_url=%s and account_id=%s'
         result = fetch_one_sql(self.conn, sql,
                                (pin_pic_url, self.account_id))
         if result:
             print('The picture has been saved.')
         else:
             time.sleep(3)
             try:
                 self.driver.find_element_by_xpath(
                     '//div[@data-test-id="boardSelectionDropdown"]').click(
                     )
                 time.sleep(5)
                 self.driver.find_element_by_xpath(
                     "//input[@id='pickerSearchField']").send_keys(
                         board_name)
                 time.sleep(5)
             except Exception as e:
                 pass
             try:
                 board_selector = self.driver.find_elements_by_xpath(
                     '//div[@data-test-id="board-picker-section"]//div[2]/div'
                 )
                 board_selector_list = []
                 for board_selector_one in board_selector:
                     board_text = board_selector_one.text
                     if board_text == board_name:
                         board_selector_list.append(board_selector_one)
                 if len(board_selector_list) > 0:
                     board_selector_list[0].click()
                     time.sleep(2)
                 else:
                     raise Exception
             except:
                 time.sleep(3)
                 self.driver.find_element_by_xpath(
                     '//div[@data-test-id="create-board"]/div').click()
                 time.sleep(3)
                 self.driver.find_element_by_name('boardName').clear()
                 time.sleep(2)
                 self.driver.find_element_by_name('boardName').send_keys(
                     board_name)
                 time.sleep(5)
                 self.driver.find_element_by_xpath(
                     "//form//button[@type='submit']").click()
                 time.sleep(3)
             if belong == 2:
                 sql = '''INSERT INTO other_pin_history (account_id, pin_url, pin_pic_url, add_time) values (
                     %s, %s, %s, %s)'''
             elif belong == 1:
                 sql = '''INSERT INTO pin_history (account_id, pin_url, pin_pic_url, add_time) values (
                     %s, %s, %s, %s)'''
             commit_sql(self.conn, sql,
                        (self.account_id, pin_url, pin_pic_url, add_time))
             time.sleep(3)
     write_txt_time()
Example #11
0
 def upload_pic(self):
     upload_flag = 1
     sql = 'SELECT * from domain where account_id=%s'
     id_result = fetch_one_sql(self.conn1, sql, self.account_id)
     if id_result:
         print('Today has been spread!')
     else:
         sql = 'SELECT * from domain where state=0 order by RAND() limit 1'
         result = fetch_one_sql(self.conn1, sql)
         if result:
             domain = result['domain']
             complete_domain = 'https://www.' + domain
             upload_pic_num = random.randint(self.upload_pic_min_num,
                                             self.upload_pic_max_num)
             print('Upload number of picture processing:', upload_pic_num)
             sql = 'SELECT * from pin_upload where saved=0 and belong_web=%s order by RAND() limit %s'
             results = fetch_all_sql(self.conn1, sql,
                                     (complete_domain, upload_pic_num))
             if results:
                 sql = "UPDATE domain set state=1, account_id=%s where domain=%s"
                 commit_sql(self.conn1, sql, (self.account_id, domain))
                 for rows in results:
                     upload_pic_path = rows['savelink']
                     upload_pic_path = upload_pic_path.replace(
                         'http://guanli.lianstone.net',
                         'http://guanli2.lianstone.net')
                     upload_pic_board = rows['saveboard']
                     upload_pic_id = rows['Id']
                     self.driver.get(upload_pic_path)
                     time.sleep(5)
                     try:
                         self.driver.find_element_by_xpath(
                             "//input[@id='pickerSearchField']").send_keys(
                                 upload_pic_board)
                         time.sleep(2)
                     except Exception as e:
                         print('Image save failed, Element not found')
                         upload_flag = 0
                     if upload_flag == 1:
                         try:
                             win32api.keybd_event(13, 0, 0, 0)
                             win32api.keybd_event(13, 0,
                                                  win32con.KEYEVENTF_KEYUP,
                                                  0)
                             time.sleep(5)
                         except Exception as e:
                             pass
                         if self.driver.page_source.find(
                                 'Sorry! We blocked this link because it may lead to spam.'
                         ) > -1:
                             print('Domain name banned!')
                             sql = "UPDATE domain set state=4 where domain=%s"
                             commit_sql(self.conn1, sql, complete_domain)
                             upload_flag = 0
                             break
                         try:
                             self.driver.find_element_by_xpath(
                                 "//div[@class='mainContainer']//div[1]/div/button"
                             ).click()
                             time.sleep(5)
                             sql = "UPDATE pin_upload set saved=1 where id=%s"
                             commit_sql(self.conn1, sql, upload_pic_id)
                             write_txt_time()
                         except Exception as e:
                             pass
                     time.sleep(3)
             else:
                 sql = "UPDATE domain set state=9 where domain=%s"
                 commit_sql(self.conn1, sql, complete_domain)
         else:
             print('No data in domain!')
     time.sleep(2)