There is a task (for myself) to write a bot to view the video on the Periscope.

Algorithm:

  1. Insert a link to the translation and give the value of the variable n = number of executions of points 3 and 4.

  2. There is a check every "n" seconds, the presence of text on the site, if the text on the site is, go to step 3.

  3. The script starts to watch the video and at the same time pings to the presence on the site of the text about the end of the broadcast, after the end of the broadcast, go to step 4.

But then errors occur (master record):

ConnectionRefusedError: [WinError 10061] Connection was not established because destination computer rejected connection request

I thought that would help fix the problem of increasing the interval of requests to the site, set the wait for 120 seconds, did not help.

The program code itself:

from selenium import webdriver from selenium.common.exceptions import NoSuchElementException import time global n n = 0 global i i = 0 def getProfile(): profile = webdriver.FirefoxProfile() profile.set_preference("browser.privatebrowsing.autostart", True) return profile def work(driver): time.sleep(120) try: driver.find_element_by_id('video_swf_0') except NoSuchElementException: print('Такого элемента на сайте существует!') driver.close() time.sleep(120) work(driver) else: print('Такой элемент на сайте существует!') driver.close() time.sleep(120) works(driver) def works(driver): while (i<=n): time.sleep(120) driver = webdriver.Firefox(firefox_profile=getProfile()) driver.implicitly_wait(5) # seconds driver.get(url_t) time.sleep(120) try: driver.find_element_by_id('video_swf_0') except NoSuchElementException: print('Такого элемента на сайте существует!') driver.close() time.sleep(120) works(driver) else: print('Такой элемент на сайте существует!') i = i + 1 time.sleep(120) works_c(driver) def works_c(driver): time.sleep(120) driver.implicitly_wait(5) driver.get(url_t) try: driver.find_element_by_id('video_swf_0') except NoSuchElementException: driver.close() time.sleep(120) works(driver) else: time.sleep(120) works_c(driver) def main(): url_t = input("Введи ссылку на трансляцию: ") n = int(input("Введи количество просмотров трансляции: ")) driver = webdriver.Firefox(firefox_profile=getProfile()) driver.implicitly_wait(5) # seconds driver.get(url_t) time.sleep(5) work(driver) if __name__ == '__main__': main() 
  • What is the server code? WinError 10061 is in python, and in the server that gave the page the answer is 405? - Igor
  • browser.privatebrowsing.autostart if not set private, then there is an error? - Igor

0