我正在编写一个应用程序,它使用MechanicalSoup从互联网上抓取一些数据。我已经介绍了login
流程等。我结束的页面包含一个html
表格。问题是,数据不完整。有一个Show more
按钮,允许用户显示完整的数据。这是它的样子(下Inspect
):
<a class="text-white btn btn-success" href="#" id="expand" style="margin-bottom:30px;">Show more</a>
我知道它调用jQuery
函数。问题是当然MechanicalSoup
不能点击它,它只能点击它的链接。
使用此代码,我可以找到此链接:
l = browser.find_link(id='expand')
print(type(l), l)
print(browser.follow_link(l))
print(browser.get_url())
我可以确定它是,bs4.Element.Tag
但是当我想遵循它时(响应是200
,所以我猜它很好)- 它不遵循它。基本上这会添加#
到页面 URL 并且在阅读页面文本后我会注意到一个差异(或者我什至尝试过launch_browser()
- 它也显示不完整的表格):
<class 'bs4.element.Tag'> <a class="text-white btn btn-success" href="#" id="expand" style="margin-bottom:30px;">Show more</a>
<Response [200]>
<page_url_without_#_at_the_end>
有什么我做错了吗?还是不可能通过该库遵循这种链接?