【发布时间】:2019-08-18 15:59:16
【问题描述】:
我正在尝试从网站抓取和获取数据。我想知道数据并将其显示到我的网站。
我无法从我的大学网站抓取数据。
我想知道正文 -> 文档 -> 文档 -> ,,,
但是当我尝试用 BeautifulSoup 爬行时,我不能这样做
我确实需要这些数据,而且我还没有使用任何其他编程语言...
我该如何爬行?
下面是图片,我认为红线会有问题。
import requests
from bs4 import BeautifulSoup
r = requests.get('http://sg.eulji.ac.kr/ejuv')
soup = BeautifulSoup(r.content, 'html')
print(soup)
HTML
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
<title>::-===-=-=-=-=-=-=-=-::</title>
<link href="/html/css/redmond_ori/jquery-ui-1.9.2.custom.min.css" media="screen" rel="stylesheet" type="text/css"/>
<script src="/html/js/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="/html/js/jquery-ui-1.9.2.custom.min.js" type="text/javascript"></script>
<!-- netFunnel연결 js파일 -->
<!-- <SCRIPT type=text/javascript src="/html/js/netfunnel/netfunnel.js" charset=utf-8></SCRIPT> -->
<script charset="euc-kr" src="/html/js/netfunnel/netfunnel.js" type="text/javascript"></script>
<style>
body {
margin : 0px;
padding : 0px;
}
.ui-widget{font-size:0.9em}
</style>
<script>
function msgAlert(msg){
$("#msg").html(msg.replace(/\r|\n/gi,"<br>"));
$("#message").dialog({
resizable: false,
width: 400,
modal: true,
closeOnEscape: false,
resizable: false,
draggable: true,
buttons: {
" close ": function() {
$( this ).dialog( "close" );
}
},
position: {
my: "center",
at: "center",
of: $("body"),
within: $("body")
}
}).height('auto');// end dialog
}
function msgConfirm(msg){
$("#msg").html(msg.replace(/\r|\n/gi,"<br>"));
$("#message").dialog({
resizable: false,
width: 500,
height: 'auto',
modal: true,
closeOnEscape: true,
resizable: false,
draggable: true,
buttons: {
" 확인 ": function() {
$( this ).dialog( "close" );
location.href= "/ejuv/login?attribute=logOut&fake="+new Date();
},
" 닫기 ": function() {
$( this ).dialog( "close" );
}
}
});// end dialog
}
function setToken(token) {
$("#token").val(token);
}
function getToken() {
return $("#token").val();
}
</script>
</head>
<body>
<div id="message" style="display:none;" title="알림"><table align="center" style="font-size:9pt;"><tr><td valign="bottom"><div id="msg"></div></td></tr></table></div>
<input id="token" name="token" type="hidden"/>
<iframe name="Main" scrolling="auto" src="/ejuv/login?attribute=login" style="position: absolute; width:100%; height:100%; border: none"></iframe>
</body>
</html>
【问题讨论】:
-
这可能是因为
hidden input中的值是使用 Javascript 动态设置的,这可能是 CSRF 令牌。如果是这种情况,您可能需要Selenium来抓取数据。
标签: python html beautifulsoup web-crawler