Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
305 views
in Technique[技术] by (71.8m points)

python - What request should I make to get the followers list from a specific profile page

I am trying to get the followers list from this profile, I tried making a GET request using python requests to the API using this request URL but it didn't seem to work, I got a METHOD_NOT_ALLOWED error. Here is my code:

import requests
address = '0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3'
followerurl = 'https://api-mainnet.rarible.com/marketplace/api/v4/followers?owner={}'.format(address)
data = requests.get(followerurl)
print(data.content)

The error I got:

{"timestamp":"2021-11-03T20:00:52.178+00:00","path":"/marketplace/api/v4/followers","status":405,"error":"Method Not Allowed","message":"","requestId":"1196e350-7513428"}'

I would appreciate any help on how to get the actual followers list I need, thank you

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try this:

import time
import requests

link = 'https://api-mainnet.rarible.com/marketplace/api/v4/followers'
params = {'user': '0xe744d23107c9c98df5311ff8c1c8637ec3ecf9f3'}
payload = {"size": 20}

with requests.Session() as s:
    s.headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36'
    res = s.post(link,params=params,json=payload)
    for item in res.json():
        print(item['owner']['name'])

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...