-1

I'm trying to access a web page using the requests library in Python. My code looks like this:

import requests
link = requests.get("www.example.com")
print(link.text)

When I run this code, I get the following output:

"I'm a teapot. You're a bot." Meaning <Response [418]>

It looks like I'm trying to access the CNN DataViz API and I'm getting a response status code of 418 indicating that the server is rejecting it and I'm a bot.

Could someone help me understand what's going on and how I can fix it? Thank you in advance for your help!

cavalcantelucas
  • 1,362
  • 3
  • 12
  • 34
Birkan
  • 121
  • 2
  • 9
  • Contact the server admin to clarify under what circumstances the server may return this message. – deceze Jan 08 '23 at 17:06

1 Answers1

2

One possible reason might be your user agent not being detected.

Consider setting it up for your request.

Instructions: Sending "User-agent" using Requests library in Python

cavalcantelucas
  • 1,362
  • 3
  • 12
  • 34
  • headers = {'User-Agent': 'My User Agent 1.0','From': 'mymailaddress@hotmail.com'} link=requests.get("https:....",headers=headers) -Still same 418 :/ – Birkan Jan 08 '23 at 16:16
  • Thank you gave me hint However, I am unable to post the solution they close this question. Link here. https://medium.com/@8birkan/im-a-teapot-you-re-a-bot-57fbdb9f6096 – Birkan Jan 09 '23 at 03:17