पर जेनरेट की गई तालिका पर मान मैंने अपने वेब ऐप के साथ एक समस्या का सामना किया है। यहाँ मेरी कोड है:स्क्रैपिंग <td> जेस्क्रिप्ट द्वारा पाइथन
@app.route('/addrec',methods = ['POST', 'GET'])
def addrec():
if g.user:
if request.method == 'POST':
#UPPER PANE
payor = request.form['payor']
receiptno = request.form['OR']
paymentmethod = request.form['paymentmethod']
naive_dt = time.strftime("%m/%d/%Y")
collectiondate = naive_dt = datetime.now()
message = request.form['message']
#LOWER PANE
url_to_scrape = 'http://localhost:5000/form'
r = requests.get(url_to_scrape)
soup = BeautifulSoup(r.text)
nature = []
for table_row in soup.select("table.inmatesList tr"):
cells = table_row.findAll('td')
if len(cells) > 0:
nature = cells[0].text.strip()
natureamt = cells[1].text.strip()
nature = {'nature': nature, 'nature': natureamt}
nature_list.append(nature)
ent = Entry(receiptno, payor,officer, paymentmethod, collectiondate,message, nature_list)
add_entry(ent)
actions="Applied"
return redirect(url_for('form'))
return redirect(url_for('home'))
आप मैं अपने रूपों से मूल्यों में से प्रत्येक के हो रही है और BeautifulSoup उपयोग करते हुए मेरे तालिका के मान scraping है देख सकते हैं। हालांकि जब मैं सबमिट बटन पर क्लिक करता हूं, तो यह हमेशा के लिए लोड होता है। मुझे ऊपरी फलक से valeus मिल रहा है लेकिन मेज में नहीं।
जिस तरह से मैं जावास्क्रिप्ट फ़ंक्शन ऑनक्लिक से अपनी कोशिकाओं को उत्पन्न कर रहा हूं। बस अगर मेरी जावास्क्रिप्ट समस्या हो सकती है। या शायद इन मानों को javascrip फ़ंक्शंस -> पायथन से निकालने का एक आसान तरीका है।
<form name="noc">
<input class="form-control input-lg" id="form" list="languages" placeholder="Search" type="text" required>
<br>
<input class="form-control input-lg" id="amount" list="languages" placeholder="Amount" type="number" required>
<br>
<button onclick="addRow(); return false;">Add Item</button>
</form>
<table id="datatable" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>Nature of Collection</th>
<th>Amount</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
</tr>
</tbody>
</table>
इन स्क्रैप मूल्यों का डेटा, मैं उन्हें अपने डेटाबेस को बचाया जा करने की उम्मीद: यहाँ मेरी जावास्क्रिप्ट कोड और एचटीएमएल
<script type="text/javascript">
function deleteRow(o){
var p=o.parentNode.parentNode;
p.parentNode.removeChild(p);
}
function addRow()
{
var table = document.getElementById("datatable"),
newRow = table.insertRow(table.length),
cell1 = newRow.insertCell(0),
cell2 = newRow.insertCell(1),
cell3 = newRow.insertCell(2),
name = document.getElementById("form").value,
amount = document.getElementById("amount").value;
delete1 = delete1 = '<input type="button" class="btn btn-danger" class="glyphicon glyphicon-trash"id="delete" value="Delete" onclick="deleteRow(this)">';
cell1.innerHTML = name;
cell2.innerHTML = amount;
cell3.innerHTML = delete1;
findTotal();
}
function findTotal(){
var arr = document.querySelectorAll("#datatable td:nth-child(2)");
var tot=0;
for(var i=0;i<arr.length;i++){
var enter_value = Number(arr[i].textContent)
if(enter_value)
tot += Number(arr[i].textContent);
}
document.getElementById('total').value = tot;
}
</script>
एचटीएमएल है। एक सेल पर यदि संभव हो तो मैं सूची को कॉलम में डालना चाहूंगा ताकि मैं उन्हें बाद में प्राप्त कर सकूं।
या क्या कोई तरीका है कि मैं क्लीनर पर सूचियां और अपने डेटाबेस के लिए बेहतर तरीका प्राप्त कर सकता हूं? किसी भी मदद की सराहना की है। धन्यवाद!
वेब-स्क्रैपिंग अपने स्वयं के वेब ऐप का एक पृष्ठ बहुत गलत लगता है, बस कह रहा है। – alecxe
@alecxe इस मामले में आप क्या सुझाव देंगे सर? मैं भी इसी समस्या में संयोग से – Rekt