Reputation: 123
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.
Upvotes: 4
Views: 1244
Reputation: 2458
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).
Upvotes: 3