是否可以使用请求模块从 Reverso Context 中获取带有单词翻译的例句?

Is it possible to get example sentences with the words' translations from Reverso Context using the requests module?

我需要从 Reverso Context.

中获取带有单词翻译的例句

首先,我尝试获取整个结果页面数据:

import requests


print(requests.get("https://context.reverso.net/translation/english-russian/cat").text)

我这里有一个问题 - 服务器知道我正在通过机器人访问它:我的应用程序没有得到我需要的东西,除此之外还得到了这个:

<p class="text" id="text-en" style="display: none">
          You've been denied access â IP blacklisted<br/>
          Your IP <b class="ip"></b> has been considered as sending illegitimate traffic to our servers.<br/>
          If you think your traffic is legitimate, please fill in the form below so we could investigate why you were blacklisted.<br/><br/>
          Thank you,<br/>
          The Reverso Team
</p>

有没有办法欺骗服务器并获取带有示例的页面?

P.S.: 我试图为这个网站找到 Python API,但找不到任何东西。

首先尝试更改您请求中的用户代理 headers 使您看起来像一个普通的网络浏览器。请参阅 https://2.python-requests.org/en/v1.0.4/user/quickstart/#custom-headers、Google 用户代理 headers。

一旦您能够访问该网站,您就可以找到这样的例句。

req = requests.get("https://context.reverso.net/translation/english-russian/cat", headers={'User-Agent': 'Mozilla/5.0'})

soup = BeautifulSoup(req.text, 'lxml')

sentences = [x.text.strip() for x in soup.find_all('span', {'class':'text'}) if '\n' in x.text]

>>> sentences[:4]
['My cat stepped on the remote.', 'Я не смотрю твои бредни, мой кот наступил на пульт.', 'Now imagine you have a cat...', 'А теперь представьте, что у вас есть кот...']