Python请求proxylist抛出的proxies.json文件

2024-04-25 05:53:54 发布

您现在位置:Python中文网/ 问答频道 /正文

出现问题的软件:

github公司:

rarcega/instagram-scraper --proxies proxies.json

它抛出的错误:

ERROR: Check is valid json type. json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None

我使用https://jsonformatter.curiousconcept.com/来验证我的proxies.json。它产生了

Warning:Duplicate key, names should be unique.[Code 23, Structure 5]

根据instagram scraper的文档:

--proxies Enable use of proxies, add a valid JSON with http or/and https urls. Example: '{"http": "http://:", "http": "https://:" }'

我试过用--proxies {"http": "http://103.250.153.202:54028"} 但它抛出相同的错误 -- proxies proxies.json也不起作用

proxies.json的内容:

{"http": "http://103.250.153.202:54028",
"http": "http://60.251.224.69:55977",
etc,
etc_last_entry}

我试图得到一个有效的json格式,遗憾的是应用程序本身的预置根本不起作用。其他人似乎让它在github上工作,所以我怀疑它是应用程序本身

我对json还不是很熟悉,所以非常感谢您的帮助

谢谢你提前抽出时间

我通过编辑软件的app.py找到了一个解决方法 替换:

try:
    if self.proxies and type(self.proxies) == str:
        self.session.proxies = json.loads(self.proxies)
except ValueError:
    self.logger.error("Check is valid json type.")
    raise

   try:
        proxies = {
            "http": "http://181.143.157.242:50942",
            "http": "http://119.82.253.63:34110"
        }
        if self.proxies: # and type(self.proxies) == str:
            #self.session.proxies = json.loads(self.proxies)
            self.session.proxies = proxies
    except ValueError:
        self.logger.error("Check is valid json type.")
        raise

Tags: andhttpsselfgithubjsonhttp软件is