I am trying to gather the followers list using python requests from this profile, when I try to send a POST request to the API with the needed headers I get an error... What am I doing wrong?
Here is my code:
from requests.api import head
address = '0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3'
followerurl = 'https://api-mainnet.rarible.com/marketplace/api/v4/followers?owner={}'.format(address)
headers = {
"authority": "api-mainnet.rarible.com",
"method": "POST",
"path": "/marketplace/api/v4/followings?owner=0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3",
"scheme": "https",
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "el,en-US;q=0.9,en;q=0.8",
"content-length": "11",
"content-type": "application/json",
"origin": "https://rarible.com",
"referer": "https://rarible.com/",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Mobile Safari/537.36",
"x-fingerprint": "822426b6593854039ff5063f26456a61",
}
data = requests.post(followerurl, headers=headers)
print(data.content)
The program standbys for 10 seconds then I get this error :
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\urllib3\connectionpool.py", line 445, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\urllib3\connectionpool.py", line 440, in _make_request
httplib_response = conn.getresponse()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 1344, in getresponse
response.begin()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 307, in begin
version, status, reason = self._read_status()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\urllib3\util\retry.py", line 532, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\urllib3\packages\six.py", line 769, in reraise
raise value.with_traceback(tb)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\urllib3\connectionpool.py", line 445, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\urllib3\connectionpool.py", line 440, in _make_request
httplib_response = conn.getresponse()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 1344, in getresponse
response.begin()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 307, in begin
version, status, reason = self._read_status()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 25, in <module>
data = requests.post(followerurl, headers=headers)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\api.py", line 117, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
Updated with the recent error, the previous one was incomplete
You aren't including the user string in the post. Try this:
import requests
address = '0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3'
followerurl = 'https://api-mainnet.rarible.com/marketplace/api/v4/followers'
headers = {
"user-agent": "Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Mobile Safari/537.36",
}
payload = {
'size': '20'}
query = {'user':'%s' %address}
data = requests.post(followerurl, params=query, json=payload, headers=headers).json()
Output:
Here's a sample of the first 2 elements in the data returned:
print(data[:2])
[{'following': {'id': '6183b55fdf746c28434736d0', 'owner': '0x1b962b82dd9af59701bdba86608cf7ea4b3efedd', 'user': '0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3', 'createDate': '2021-11-04T10:26:39.633+00:00', 'deleted': False}, 'owner': {'id': '0x1b962b82dd9af59701bdba86608cf7ea4b3efedd', 'type': 'USER', 'name': 'MASYANA58^^.', 'image': 'ipfs://ipfs/QmZ7V5d95bDKhHPg6UAWZ5HhjHxUzwtJeyiJBCwVV2UPQR', 'shortUrl': 'masyana58', 'website': 'https://www.instagram.com/invites/contact/?i=15i2h5oepcxgc&utm_content=5zmtkl6', 'description': 'Hello, i am masyana58.I am here to show you my imagination and my vision.I hope, you will enjoy my creations', 'badges': ['VERIFIED'], 'cover': 'ipfs://ipfs/QmdB1UP6zVLfXNeCEw3zr9fxb5uP1ArhJgPh4ossgq7jwo', 'coverMedia': [{'url': 'https://img.rarible.com/prod/image/upload/prod-users/0x1b962b82dd9af59701bdba86608cf7ea4b3efedd/cover/QmdB1UP6zVLfXNeCEw3zr9fxb5uP1ArhJgPh4ossgq7jwo', 'sizeType': 'ORIGINAL', 'contentType': 'IMAGE'}, {'url': 'https://img.rarible.com/prod/image/upload/t_cover_preview/prod-users/0x1b962b82dd9af59701bdba86608cf7ea4b3efedd/cover/QmdB1UP6zVLfXNeCEw3zr9fxb5uP1ArhJgPh4ossgq7jwo', 'sizeType': 'PREVIEW', 'contentType': 'IMAGE', 'dimension': {'width': 1000, 'height': 200}, 'cropMode': 'CROP'}, {'url': 'https://img.rarible.com/prod/image/upload/t_cover_big/prod-users/0x1b962b82dd9af59701bdba86608cf7ea4b3efedd/cover/QmdB1UP6zVLfXNeCEw3zr9fxb5uP1ArhJgPh4ossgq7jwo', 'sizeType': 'BIG', 'contentType': 'IMAGE', 'dimension': {'width': 2200, 'height': 400}, 'cropMode': 'CROP'}, {'url': 'https://img.rarible.com/prod/image/upload/t_cover_placeholder/prod-users/0x1b962b82dd9af59701bdba86608cf7ea4b3efedd/cover/QmdB1UP6zVLfXNeCEw3zr9fxb5uP1ArhJgPh4ossgq7jwo', 'sizeType': 'PLACEHOLDER', 'contentType': 'IMAGE', 'dimension': {'width': 55, 'height': 10}, 'cropMode': 'CROP'}], 'imageMedia': [{'url': 'https://img.rarible.com/prod/image/upload/prod-users/0x1b962b82dd9af59701bdba86608cf7ea4b3efedd/avatar/QmZ7V5d95bDKhHPg6UAWZ5HhjHxUzwtJeyiJBCwVV2UPQR', 'sizeType': 'ORIGINAL', 'contentType': 'IMAGE'}, {'url': 'https://img.rarible.com/prod/image/upload/t_avatar_preview/prod-users/0x1b962b82dd9af59701bdba86608cf7ea4b3efedd/avatar/QmZ7V5d95bDKhHPg6UAWZ5HhjHxUzwtJeyiJBCwVV2UPQR', 'sizeType': 'PREVIEW', 'contentType': 'IMAGE', 'dimension': {'width': 30, 'height': 30}, 'cropMode': 'THUMB'}, {'url': 'https://img.rarible.com/prod/image/upload/t_avatar_big/prod-users/0x1b962b82dd9af59701bdba86608cf7ea4b3efedd/avatar/QmZ7V5d95bDKhHPg6UAWZ5HhjHxUzwtJeyiJBCwVV2UPQR', 'sizeType': 'BIG', 'contentType': 'IMAGE', 'dimension': {'width': 240, 'height': 240}, 'cropMode': 'THUMB'}], 'followings': 334, 'followers': 124, 'blacklisted': False, 'blockchain': 'ETHEREUM'}, 'user': {'id': '0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3', 'type': 'USER', 'name': 'ZafGod.eth', 'image': 'ipfs://ipfs/QmaM3Lvd8kiwCekq6cuhWh5SA7RpbN2upQM1R6QoefWHuS', 'shortUrl': 'artshop', 'website': 'http://Instagram.com/zafgod', 'emoji': '💀', 'description': 'Artist-- 👽 \nJoin the club on discord https://discord.com/invite/NHc7HQv', 'badges': ['VERIFIED'], 'cover': 'ipfs://ipfs/Qmc6qi78MyEWwvyCa3gnSA8rKCu4jVb19nZorn3NccfgcJ', 'coverMedia': [{'url': 'https://img.rarible.com/prod/image/upload/prod-users/0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3/cover/Qmc6qi78MyEWwvyCa3gnSA8rKCu4jVb19nZorn3NccfgcJ', 'sizeType': 'ORIGINAL', 'contentType': 'IMAGE'}, {'url': 'https://img.rarible.com/prod/image/upload/t_cover_preview/prod-users/0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3/cover/Qmc6qi78MyEWwvyCa3gnSA8rKCu4jVb19nZorn3NccfgcJ', 'sizeType': 'PREVIEW', 'contentType': 'IMAGE', 'dimension': {'width': 1000, 'height': 200}, 'cropMode': 'CROP'}, {'url': 'https://img.rarible.com/prod/image/upload/t_cover_big/prod-users/0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3/cover/Qmc6qi78MyEWwvyCa3gnSA8rKCu4jVb19nZorn3NccfgcJ', 'sizeType': 'BIG', 'contentType': 'IMAGE', 'dimension': {'width': 2200, 'height': 400}, 'cropMode': 'CROP'}, {'url': 'https://img.rarible.com/prod/image/upload/t_cover_placeholder/prod-users/0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3/cover/Qmc6qi78MyEWwvyCa3gnSA8rKCu4jVb19nZorn3NccfgcJ', 'sizeType': 'PLACEHOLDER', 'contentType': 'IMAGE', 'dimension': {'width': 55, 'height': 10}, 'cropMode': 'CROP'}], 'imageMedia': [{'url': 'https://img.rarible.com/prod/image/upload/prod-users/0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3/avatar/QmaM3Lvd8kiwCekq6cuhWh5SA7RpbN2upQM1R6QoefWHuS', 'sizeType': 'ORIGINAL', 'contentType': 'IMAGE'}, {'url': 'https://img.rarible.com/prod/image/upload/t_avatar_preview/prod-users/0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3/avatar/QmaM3Lvd8kiwCekq6cuhWh5SA7RpbN2upQM1R6QoefWHuS', 'sizeType': 'PREVIEW', 'contentType': 'IMAGE', 'dimension': {'width': 30, 'height': 30}, 'cropMode': 'THUMB'}, {'url': 'https://img.rarible.com/prod/image/upload/t_avatar_big/prod-users/0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3/avatar/QmaM3Lvd8kiwCekq6cuhWh5SA7RpbN2upQM1R6QoefWHuS', 'sizeType': 'BIG', 'contentType': 'IMAGE', 'dimension': {'width': 240, 'height': 240}, 'cropMode': 'THUMB'}], 'followings': 3752, 'followers': 2782, 'blacklisted': False, 'blockchain': 'ETHEREUM'}, 'id': '6183b55fdf746c28434736d0'}, {'following': {'id': '6183a81cb8c1e71a27395adc', 'owner': '0x7d2185a5bb721d8cb9d8b8382d9739c33bb8beb3', 'user': '0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3', 'createDate': '2021-11-04T09:30:04.044+00:00', 'deleted': False}, 'owner': {'id': '0x7d2185a5bb721d8cb9d8b8382d9739c33bb8beb3', 'type': 'USER', 'name': 'TGiacinto', 'image': 'ipfs://ipfs/QmQCroMLcZaRgAtjAhfLbMARwz1yMVP5ppt9KBFcF8TWso', 'shortUrl': 'tgiacinto', 'badges': [], 'coverMedia': [], 'imageMedia': [{'url': 'https://img.rarible.com/prod/image/upload/prod-users/0x7d2185a5bb721d8cb9d8b8382d9739c33bb8beb3/avatar/QmQCroMLcZaRgAtjAhfLbMARwz1yMVP5ppt9KBFcF8TWso', 'sizeType': 'ORIGINAL', 'contentType': 'IMAGE'}, {'url': 'https://img.rarible.com/prod/image/upload/t_avatar_preview/prod-users/0x7d2185a5bb721d8cb9d8b8382d9739c33bb8beb3/avatar/QmQCroMLcZaRgAtjAhfLbMARwz1yMVP5ppt9KBFcF8TWso', 'sizeType': 'PREVIEW', 'contentType': 'IMAGE', 'dimension': {'width': 30, 'height': 30}, 'cropMode': 'THUMB'}, {'url': 'https://img.rarible.com/prod/image/upload/t_avatar_big/prod-users/0x7d2185a5bb721d8cb9d8b8382d9739c33bb8beb3/avatar/QmQCroMLcZaRgAtjAhfLbMARwz1yMVP5ppt9KBFcF8TWso', 'sizeType': 'BIG', 'contentType': 'IMAGE', 'dimension': {'width': 240, 'height': 240}, 'cropMode': 'THUMB'}], 'followings': 13, 'followers': 9, 'blacklisted': False, 'blockchain': 'ETHEREUM'}, 'user': {'id': '0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3', 'type': 'USER', 'name': 'ZafGod.eth', 'image': 'ipfs://ipfs/QmaM3Lvd8kiwCekq6cuhWh5SA7RpbN2upQM1R6QoefWHuS', 'shortUrl': 'artshop', 'website': 'http://Instagram.com/zafgod', 'emoji': '💀', 'description': 'Artist-- 👽 \nJoin the club on discord https://discord.com/invite/NHc7HQv', 'badges': ['VERIFIED'], 'cover': 'ipfs://ipfs/Qmc6qi78MyEWwvyCa3gnSA8rKCu4jVb19nZorn3NccfgcJ', 'coverMedia': [{'url': 'https://img.rarible.com/prod/image/upload/prod-users/0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3/cover/Qmc6qi78MyEWwvyCa3gnSA8rKCu4jVb19nZorn3NccfgcJ', 'sizeType': 'ORIGINAL', 'contentType': 'IMAGE'}, {'url': 'https://img.rarible.com/prod/image/upload/t_cover_preview/prod-users/0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3/cover/Qmc6qi78MyEWwvyCa3gnSA8rKCu4jVb19nZorn3NccfgcJ', 'sizeType': 'PREVIEW', 'contentType': 'IMAGE', 'dimension': {'width': 1000, 'height': 200}, 'cropMode': 'CROP'}, {'url': 'https://img.rarible.com/prod/image/upload/t_cover_big/prod-users/0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3/cover/Qmc6qi78MyEWwvyCa3gnSA8rKCu4jVb19nZorn3NccfgcJ', 'sizeType': 'BIG', 'contentType': 'IMAGE', 'dimension': {'width': 2200, 'height': 400}, 'cropMode': 'CROP'}, {'url': 'https://img.rarible.com/prod/image/upload/t_cover_placeholder/prod-users/0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3/cover/Qmc6qi78MyEWwvyCa3gnSA8rKCu4jVb19nZorn3NccfgcJ', 'sizeType': 'PLACEHOLDER', 'contentType': 'IMAGE', 'dimension': {'width': 55, 'height': 10}, 'cropMode': 'CROP'}], 'imageMedia': [{'url': 'https://img.rarible.com/prod/image/upload/prod-users/0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3/avatar/QmaM3Lvd8kiwCekq6cuhWh5SA7RpbN2upQM1R6QoefWHuS', 'sizeType': 'ORIGINAL', 'contentType': 'IMAGE'}, {'url': 'https://img.rarible.com/prod/image/upload/t_avatar_preview/prod-users/0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3/avatar/QmaM3Lvd8kiwCekq6cuhWh5SA7RpbN2upQM1R6QoefWHuS', 'sizeType': 'PREVIEW', 'contentType': 'IMAGE', 'dimension': {'width': 30, 'height': 30}, 'cropMode': 'THUMB'}, {'url': 'https://img.rarible.com/prod/image/upload/t_avatar_big/prod-users/0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3/avatar/QmaM3Lvd8kiwCekq6cuhWh5SA7RpbN2upQM1R6QoefWHuS', 'sizeType': 'BIG', 'contentType': 'IMAGE', 'dimension': {'width': 240, 'height': 240}, 'cropMode': 'THUMB'}], 'followings': 3752, 'followers': 2782, 'blacklisted': False, 'blockchain': 'ETHEREUM'}, 'id': '6183a81cb8c1e71a27395adc'}]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.