1

我在执行我的 python 脚本时遇到问题。我不断收到同样的错误。错误是:

Failed to establish a new connection: [Errno 10061] No connection could be made because the target machine actively refused it. 

请注意,我的防火墙已禁用,而且我没有防病毒软件。此外,这个相同的脚本在家里的另一台电脑上运行良好,但我在这个系统上需要它。

我想要做的是连接到 API。我的代码是:

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)

请帮我 :)

4

1 回答 1

1

基本上,这意味着在您尝试通过您的 IP 地址连接的端口上没有任何监听。您可能需要检查防火墙,因为它可能会阻止某个端口。这可能会发生,因为您的防火墙可能会保护您免受黑客攻击,因为您的信息可能会从中泄露。

于 2019-05-07T15:27:02.860 回答