我从列表中显示了链接,但它们未被解析为“可点击”
我的模板如下所示:
<html>
<body>
<h2>All listing</h2>
{% for link in name %}
<div>
<ul>
<li> {{ link }}</li>
</ul>
</div>
{% endfor %}
</body>
</html>
我希望以上内容会将链接返回为可点击但是我只看到原始html如下:
<a href="http://www.businessghana.com/portal/jobs/index.php?op=getJobInfo&id=103536">Sales Executives needed urgently in Accra</a>
<a href="http://www.businessghana.com/portal/jobs/index.php?op=getJobInfo&id=120007">Direct Sales Officers</a>
<a href="http://www.businessghana.com/portal/jobs/index.php?op=getJobInfo&id=120010">Fleet Engineer</a>
<a href="http://www.businessghana.com/portal/jobs/index.php?op=getJobInfo&id=119866">Business Development Manager</a>
<a href="http://www.businessghana.com/portal/jobs/index.php?op=getJobInfo&id=119846">Administrative & Accounts Assistant Urgently Needed</a>
<a href="http://www.businessghana.com/portal/jobs/index.php?op=getJobInfo&id=119772">Quality Control Officer</a>
当我使用HttpResponse使用下面的视图显示链接时,我得到了我想要的东西
def businessghana(request):
site = "http://www.businessghana.com/portal/jobs"
hdr = {'User-Agent' : 'Mozilla/5.0'}
req = urllib2.Request(site, headers=hdr)
jobpass = urllib2.urlopen(req)
soup = BeautifulSoup(jobpass)
for tag in soup.find_all('a', href = True):
tag['href'] = urlparse.urljoin('http://www.businessghana.com/portal/', tag['href'])
html = map(str, soup.find_all('a', href = re.compile('.getJobInfo')))
return HttpResponse(html)
但是一旦我添加了模板,我就不再这样了。 如何将我的链接解析为可点击而不是原始html?
感谢所有人提前和愉快的假期,
最高