mechanize可以完全替换为请求[python]

2024-06-26 17:41:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我在GitHub上找到了一个python2项目,想把它转换成python3。我只是想知道requests和mechanize是否基本相同,是否可以相互替换。在


Tags: 项目githubrequestspython3mechanize基本相同python2
1条回答
网友
1楼 · 发布于 2024-06-26 17:41:15

不。虽然它们有一些相同的功能,但它们绝对不一样。Mechanize似乎比请求具有更多的特性。Mechanize能够“解决”页面上的表单,其中请求更多的只是提取页面的原始HTML或与web API交互。对于获取此功能的请求,需要另一个库。可以用MechanicalSoup替换Mehchanize。实际上,创建者启动了MechanicalSoup,因为Mechanize还没有移植到3.*中。在

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

相关问题 更多 >