Reputation: 13
I'm having trouble executing my python script. I keep getting the same error. The error is:
Failed to establish a new connection: [Errno 10061] No connection could be made because the target machine actively refused it.
Please note that my firewall is disabled and further I have no antivirus software. Also, this same script is working fine on another pc in the house but I need it on this system.
What I'm trying to do is connecting to an API. My code is:
import requests
import time
import pycurl
import re
import certifi
import random
from pycurl import Curl
from io import BytesIO
from selenium.webdriver.common.keys import Keys
from selenium import webdriver
from selenium.webdriver.chrome import options
from selenium.webdriver.common.action_chains import ActionChains
from random import randint
import os
import glob
import subprocess
aantalkeer = 1
max_aantalkeer = 2
while aantalkeer <= max_aantalkeer:
print(str(aantalkeer) + "e keer")
buffer = BytesIO()
name = ["Lesli", "Prudence", "Paz", "Geraldo", "Regan", "Creola", "Adella", "Elsa", "Onie", "Abdoel", "Rochel",
"Irwin", "Inocencia", "Linnea", "Ann", "Tomika", "Elvia", "Hosea", "Otha", "Bernardina"]
browsertypes = ["mimic", "stealthfox", "mimic", "mimic", "mimic"]
language = "nl-NL, nl;q=0.9,en-US;q=0.8,en;q=0.7"
secure_random = random.SystemRandom()
name = secure_random.choice(name)
browsertype = secure_random.choice(browsertypes)
token = "a01f2992e57c9b24f1ae5d085189a5ce8a888fd6"
postfields = '{ "name": "' + str(name) + '", "browser": "' + str(browsertype) + '", "os": "win",' \
' "navigator": { "language": "nl-NL,en-US;q=0.9,en;q=0.8" },' \
' "timezone": { "mode": "FAKE", "fillBasedOnExternalIp": true },' \
' "geolocation": { "mode": "PROMPT", "fillBasedOnExternalIp": true },' \
' "webRTC": { "mode": "FAKE", "fillBasedOnExternalIp": true },' \
' "audioContext": { "mode": "NOISE" }, "canvas": { "mode": "NOISE" } }'
headers = ['Content-type: application/json', 'Authorization: BasicBase64EncodedApiKeyAndPassword']
c = Curl = pycurl.Curl()
c.setopt(pycurl.CAINFO, certifi.where())
c.setopt(c.URL, 'https://api.multiloginapp.com/v2/profile?token='+token+'&defaultMode=REAL')
c.setopt(c.HTTPHEADER, headers)
c.setopt(c.POST, 1)
c.setopt(c.POSTFIELDS, postfields)
c.setopt(c.WRITEDATA, buffer)
c.perform()
c.close()
body= bytes = buffer.getvalue()
body= stri = body.decode('utf-8')
body= stri = re.sub('[^A-Za-z0-9-]+', ' ', body)
body= stri = body.replace('uuid ', '')
body= stri = body.replace('/s', '')
profileid = re.sub('^(\s+)', "", body)
profileid = re.sub(r'\s+$', "", profileid)
print(profileid)
mla_port = "35000"
mla_url = 'https://localhost:'+ mla_port +'/api/v1/profile/start?automation=true&profileId=' + profileid
resp = requests.get(mla_url)
json = resp.json()
opts = options.DesiredCapabilities()
googlelinks = ["https://www.google.com", "https://www.google.nl"]
secure_random = random.SystemRandom()
googlelink = secure_random.choice(googlelinks)
Please help me :)
Upvotes: 1
Views: 2001
Reputation: 121
Basically, it means that there is nothing listening at the port you were trying to connect to through your IP address. You might need to check your firewall as it might block a certain port. This may happen as your firewall may be protecting you from hackers as your information may be leaked from this.
Upvotes: 1