more prints
This commit is contained in:
5
main.py
5
main.py
@@ -28,6 +28,7 @@ async def get_latest_post(subreddit):
|
||||
headers = {"User-Agent": "Mozilla/5.0 (compatible; ich_iel-Bot/0.1)"}
|
||||
response = requests.get(url, headers=headers)
|
||||
if response.status_code == 200:
|
||||
if response.headers.get("Content-Type", "").startswith("application/json"):
|
||||
try:
|
||||
data = response.json()
|
||||
print(f"Fetched data from Reddit: {data}")
|
||||
@@ -39,6 +40,10 @@ async def get_latest_post(subreddit):
|
||||
return post["title"], post["url"]
|
||||
except (KeyError, json.JSONDecodeError):
|
||||
return None, None
|
||||
else:
|
||||
print(f"Unexpected content type from Reddit: {response.headers.get('Content-Type')}")
|
||||
print(f"Response content: {response.text}")
|
||||
return None, None
|
||||
else:
|
||||
print(f"Failed to fetch Reddit data (maybe a block?): {response.status_code}")
|
||||
return None, None
|
||||
|
||||
Reference in New Issue
Block a user