0

当我发布我的会话信息时,我得到了 200 个箭头。但是当我向不同的 url 发出请求时,我得到 403。如果你能提供帮助,我将不胜感激。

我正在用请求库做这个的同步版本。我正在得到结果。谢谢你为我做的一切。

def urlsapi(self, ip):
    return ['http://'+ip+'/arp.cgi',
            'http://'+ip+'/sroutes.cgi',
            'http://'+ip+'/status.cgi']

async def RSession(self, ip):

        self.responses_by_ip = {}

        async with aiohttp.ClientSession()as session: 
            async with session.post(
                url='https://'+ip+'/api/auth',
                data={'username': 'username','password': 'password'},
                ssl=False,timeout=5)as Err:
                self.responses = []
                for url in self.urlsapi(ip):
                    url = url.format(ip)

                    task = asyncio.ensure_future(
                        self.qetqetir(url, session, ip))
                    self.responses.append(task)
                view = await asyncio.gather(*self.responses)
                self.responses_by_ip.update({"Data": view})


        return self.responses_by_ip

async def qetqetir(self, url, session, ip):
    r = await session.get(url=url,ssl=False)
    return({"Ip": ip, "Data1": r.json() if r.status == 200 else r.status})

 async def endPoint(self):
        lis2 = []

        for d in  self.ubnt60ghzList():
           ds = asyncio.ensure_future(self.RSession(d))
           lis2.append(ds)
        views = await asyncio.gather(*lis2)
        print(views)

        return lis2


d = Ubntos()
asyncio.run(d.endPoint())

输出:

POST
200
POST

403
GET
403
4

0 回答 0