bizarticle
This commit is contained in:
@@ -7,7 +7,7 @@ from src.database import db_session, read_json
|
||||
|
||||
|
||||
def get_all():
|
||||
return Article.query.all()
|
||||
return Article.query.order_by(Article.published_date.desc()).all()
|
||||
|
||||
def search(s):
|
||||
return Article.query.filter(Article.title.like("%"+s+"%")).all()
|
||||
return Article.query.filter(Article.title.like("%"+s+"%")).order_by(Article.published_date.desc()).all()
|
||||
|
||||
@@ -135,6 +135,30 @@ def fsarcharticle(url, raw):
|
||||
d["author"]=None
|
||||
return {"article": d}
|
||||
|
||||
def fsbizarticle(url, raw):
|
||||
sp=BeautifulSoup(raw)
|
||||
d={}
|
||||
h=sp.find("h1", {"class": "entry-title"})
|
||||
if h is not None:
|
||||
d["title"]=h.text.strip()
|
||||
d["url"]=url
|
||||
h=sp.find("time", {"class": "entry-date"})
|
||||
if h is not None:
|
||||
d["published"] = parse(h.attrs["datetime"])
|
||||
else:
|
||||
d["published"]=None
|
||||
h=sp.find("div", {"class": "entry-content"})
|
||||
if h is not None:
|
||||
d["text"]=h.encode_contents().strip()
|
||||
d["image"]=""
|
||||
d["sourcetype"]="fsbizarticle"
|
||||
d["section"]="fsbiz"
|
||||
h=sp.find("span", {"class": "author"})
|
||||
d["author"]=None
|
||||
if h is not None:
|
||||
d["author"]=h.find("a").text.strip()
|
||||
return {"article": d}
|
||||
|
||||
def fetindex(url, raw):
|
||||
if raw is None:
|
||||
raise Error
|
||||
|
||||
Reference in New Issue
Block a user