0

I am trying to pull transactions for a list of addresses:

wallet_addresses = ['0x7abe0ce388281d2acf297cb089caef3819b13448', '0xC098B2a3Aa256D2140208C3de6543aAEf5cd3A94',
                '0x2FAF487A4414Fe77e2327F0bf4AE2a264a776AD2']


for address in wallet_addresses:
    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)' 'Chrome/80.0.3987.149 Safari/537.36'}
    url = f'https://etherscan.io/address/{address}#tokentxns'
    response = requests.get(url,headers=headers)
    result = response.json()
    print(result)

However, the above gives the following error:

JSONDecodeError: Expecting value: line 2 column 1 (char 1)

How can I get the contents of the page for each address?

EDIT: What I am hoping for is a json of the table contents on the page to convert to a DataFrame.

1 Answer 1

2

You're trying to convert the server's response into json, but it's not json. Try getting the raw content instead:

...
result = response.content
print(content)

etherscan.io has an API, which should return the same data in a more easily consumable JSON format

Sign up to request clarification or add additional context in comments.

2 Comments

That worked but gives raw data. What I was hoping for is some sort of json format to convert to a DataFrame. Any thoughts?
@MathMan99 Updated my answer re your Q

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.