4

I found a python2 project on GitHub, and wanted to transalte it into python3. I just wondered if requests and mechanize are basically the same, and can be replaced with each other.

Tsumugi Kotobuki
  • 103
  • 1
  • 1
  • 10

1 Answers1

3

No. While they have some of the same features they are definitely not the same. Mechanize appears to have more features than requests. Mechanize has the ability to "solve" forms on a page where Requests is more for just pulling the raw HTML of a page or interacting with a web API. For requests to gain this functionality requires another library. You could replace Mehchanize with MechanicalSoup. In fact the creator started MechanicalSoup because Mechanize isn't ported to 3.* yet.

I was a fond user of the Mechanize library, but unfortunately it's incompatible with Python 3 and development is inactive. MechanicalSoup provides a similar API, built on Python giants Requests (for http sessions) and BeautifulSoup (for document navigation).

Sleep Deprived Bulbasaur
  • 2,368
  • 4
  • 21
  • 33