在python中使用beautifulsoup点击链接 [英] Clicking link using beautifulsoup in python

查看:28
本文介绍了在python中使用beautifulsoup点击链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在机械化中,我们通过使用 follow_link 或 click_link 点击链接.美汤有没有类似的东西点击网页上的链接?

In mechanize we click links either by using follow_link or click_link. Is there a similar kind of thing in beautiful soup to click a link on a web page?

推荐答案

BeautifulSoup 是一个 HTML 解析器.

BeautifulSoup is an HTML parser.

进一步讨论实际上取决于您所处的具体情况以及特定网页的复杂性.

Further discussion really depends on the concrete situation you are in and the complexity of the particular web page.

如果您需要与网页交互:提交表单、单击按钮、滚动等 - 您需要使用使用真实浏览器的工具,例如 .

If you need to interact with a web-page: submit forms, click buttons, scroll etc - you need to use a tool that utilizes a real browser, like selenium.

在某些情况下,例如,如果提交表单时不涉及 javascript,mechanize 也适合你.

In certain situations, for example, if there is no javascript involved in submitting a form, mechanize would also work for you.

而且,有时您只需点击带有 urllib2<的链接即可处理它/code>requests.

And, sometimes you can handle it by simply following the link with urllib2 or requests.

这篇关于在python中使用beautifulsoup点击链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆