如何从 python 中的网站获取一定数量的单词

How to get a certain number of words from a website in python

我想使用请求库和 discord.py 库从 cheat.sh 获取数据....但是由于 discord 一次只允许发送 2000 个字符,我想只获取一定数量的 words/digits/newline,比如 1800。我该怎么做?

一小段代码示例展示了我的想法

import requests

url = "https://cheat.sh/python/string+annotations" #this gets the docs of string annotation in python

response = requests.get(url)
data = response.text # This gives approximately 2403 words...but i want to get only 1809 words
print(data)
 import requests

 url = "https://cheat.sh/python/string+annotations" #this gets the docs of string 
 annotation in python

 response = requests.get(url)
 data = response.text[:1800]
 print(data)

This will be the correct code