在python中使用beautifulsoup点击链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23679480/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Clicking link using beautifulsoup in python
提问by user3286661
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?
在机械化中,我们通过使用 follow_link 或 click_link 单击链接。美汤里有没有类似的东西点击网页上的链接?
采纳答案by alecxe
BeautifulSoup
is an HTML parser.
BeautifulSoup
是一个 HTML解析器。
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
.
如果您需要与网页交互:提交表单、单击按钮、滚动等 - 您需要使用使用真实浏览器的工具,例如selenium
.
In certain situations, for example, if there is no javascript involved in submitting a form, mechanize
would also work for you.
在某些情况下,例如,如果提交表单时不涉及 javascript,它mechanize
也适用于您。
And, sometimes you can handle it by simply following the link with urllib2
or requests
.