我想解析代码的描述部分。我怎么能在神社做到这一点?相关代码如下:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
window.onload=function (){
$("#searcher").submit(function(ev) {
/* stop form from submitting normally */
ev.preventDefault();
$.post("/searchRSS", $("#searcher").serialize(),function(o){console.log(o);document.getElementById("result").innerHTML=o;});
})};
</script>
<form id="searcher" method="post" action="#">
<input type="text" id="query" name="query" required/>
<input type="submit" value="Get Feed"/>
</form>
<div id="result">
<table>
{% for row in posts %}
<tr><td>{{ row.title }}</td></tr>
<tr><td>{{ row.date }}</td></tr>
<tr><td>{{ row.description }}</td></tr>
{% endfor %}
</table>
</div>
管理 searchRSS 的代码如下:
@app.route('/searchRSS',methods=['POST'])
def search_results():
feed = feedparser.parse("http://news.google.com/news?hl=en&gl=in&q="+request.form['query']+"&um=1&output=rss" )
print feed['feed']
posts = []
for i in range(0,len(feed['entries'])):
posts.append({
'title': feed['entries'][i].title,
'date': feed['entries'][i].updated,
'description': feed['entries'][i].description
})
print posts
return render_template('index.html', posts=posts)
通过解析我的意思是我只想显示相关信息而不是 HTML/CSS 标签。