我正在尝试从这个网站-https://www.timeshighereducation.com/world-university-rankings/2018/world-ranking#!/page/0/length/25/sort_by/rank/sort_order/asc/cols/scores获取孔表(所有1000+所大学)。在
为此,我使用了以下库-requests和BeautifulSoup,我的代码是:
import requests
from bs4 import BeautifulSoupenter
html_content = requests.get('https://www.timeshighereducation.com/world-university-rankings/2018/world-ranking#!/page/0/length/25/sort_by/rank/sort_order/asc/cols/stats')
soup = bs4.BeautifulSoup(html_content, 'lxml')
我要找张桌子:
^{pr2}$但结果是,我看不到表本身<tbody>
、行<tr>
和列<td>
。在
HTML代码:
请帮助mу从该站点获取所有信息并从中构建一个数据帧。在
试试下面的方法。如果您查看devtools下network选项卡中的networkactivityatxhr部分,就可以获得url。但是,从json响应中获取数据的脚本应该是这样的。在
输出:
^{pr2}$站点似乎是动态的,因为快速检查源代码就会发现表本身并不是在DOM中呈现的。因此,您需要使用浏览器操作工具,如
selenium
:输出示例:
^{pr2}$相关问题 更多 >
编程相关推荐