2015-09-17 87 views
-1

我需要從使用django框架獲取數據,並寫入數據庫。行使用javascript添加到表格中。例如:Django從數據庫的html表中獲取數據

<table id="tbl" > 
<thead > 
    <tr> 
     <th>Name</th>   
     <th>Phone</th> 
     <th>Sarlay</th> 
     <th>P1</th> 
     <th>P2</th> 
    </tr> 
</thead> 
<tbody class="scrollContent"> 
</tbody> 
</table> 
<button type="button" onclick="Add_Row()" class="btn btn-primary">Add</button> 
<script > 
function Add_Row() 
{ 
document.getElementById("scrolltable").insertRow(-1).innerHTML = ' <tr><td><input class="form-control" name="inp" type="text" value=""/></td><td><input class="form-control" name="inp" type="text" value=""/></td><td><input class="form-control" name="inp" type="text" value=""/></td><td><input class="form-control" name="inp" type="text" value=""/></td><td><input class="form-control" name="inp" type="text" value=""/></td></tr>'; 
} 
</script> 

誰知道如何從該表中獲取數據?

P.S.我試圖用BeautifulSoup來解決這個問題,但它並沒有幫助我。

+0

它是現在的形式,這是一個接近的投票減輕棒。更新問題以顯示您嘗試的內容。 BeautifulSoup不會工作,因爲你似乎正在生成與JavaScript的頁面。 – e4c5

+0

這與Django和BeautifulSoup都沒有關係 – Raptor

回答

0

您不應該從沒有所有者權限的網站解析數據。

一種方法是使用瀏覽器的「開發人員工具」或檢查該頁面的源代碼,並從js填充這些表格中找出它的位置。如果你幸運的話,你可能會找到一些合理的格式(json或xml)。