Search code examples
pythonweb-scrapingpython-requestsurllib

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


I need to get example sentences with the words' translations from Reverso Context.

Firstly, I tried to get the whole results page data:

import requests


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

And I have a problem here - the server knows I'm accessing it via a bot: my app doesn't get what I need and get this among other things:

<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>

Is there a way to trick the server and get the page with examples?

P.S.: I tried to find a Python API for this web-site, but couldn't find anything.


Solution

  • First try changing the user agent in your request headers to make yourself look like a normal web browser. See https://2.python-requests.org/en/v1.0.4/user/quickstart/#custom-headers, Google user agent headers.