Error with rewards script.
Closed this issue · 1 comments
Bhaney44 commented
Running rewards.py
:
def get_data():
html = urlopen("https://algoexplorer.io/address/25S2YKMG2E3L5RTFI67NTSWFJJQHBTDULAIN7TQVXWB3E4E5Y6BPG3O44I")
soup = BeautifulSoup(html, 'html.parser')
Sender_Data = soup.find_all('a')
get_data()
Error:
(base) Brians-MacBook-Pro:desktop brianhaney$ python3 rewards.py
Traceback (most recent call last):
File "rewards.py", line 20, in <module>
get_data()
File "rewards.py", line 12, in get_data
html = urlopen("https://algoexplorer.io/address/25S2YKMG2E3L5RTFI67NTSWFJJQHBTDULAIN7TQVXWB3E4E5Y6BPG3O44I")
File "/opt/anaconda3/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/opt/anaconda3/lib/python3.7/urllib/request.py", line 531, in open
response = meth(req, response)
File "/opt/anaconda3/lib/python3.7/urllib/request.py", line 641, in http_response
'http', request, response, code, msg, hdrs)
File "/opt/anaconda3/lib/python3.7/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/opt/anaconda3/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/opt/anaconda3/lib/python3.7/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden
Tee-py commented
import requests
from bs4 import BeautifulSoup
def get_data():
try:
#html = urlopen("https://algoexplorer.io/address/25S2YKMG2E3L5RTFI67NTSWFJJQHBTDULAIN7TQVXWB3E4E5Y6BPG3O44I/")
html = requests.get("https://algoexplorer.io/address/25S2YKMG2E3L5RTFI67NTSWFJJQHBTDULAIN7TQVXWB3E4E5Y6BPG3O44I/")
except Exception as e:
print(e)
return
soup = BeautifulSoup(html.content, 'html.parser')
Sender_Data = soup.find_all('a')
print(Sender_Data)
get_data()
Try using requests instead of urlopen @Bhaney44