Python
- 6 ответов
- 0 вопросов
2
Вклад в тег
from flask import render_template
from urllib.request import urlopen
from urllib.error import HTTPError
from bs4 import BeautifulSoup
@app.route("/links/")
def parse():
try:
html = urlopen("http://www.site.ru/").read()
except HTTPError as e:
print(e)
soup = BeautifulSoup(html, 'lxml');
links = soup.findAll('a')
return render_template('template.html', links=links)