mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
test
This commit is contained in:
parent
5ebdad391b
commit
6413ddf148
@ -13,6 +13,8 @@ import requests
|
|||||||
import bleach
|
import bleach
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
|
from lxml import html
|
||||||
|
|
||||||
api_url = 'https://httpstatuses.com/'
|
api_url = 'https://httpstatuses.com/'
|
||||||
|
|
||||||
|
|
||||||
@ -49,6 +51,25 @@ def fetch_result(query):
|
|||||||
return "HTTP error: " + e.message
|
return "HTTP error: " + e.message
|
||||||
return "testing"
|
return "testing"
|
||||||
|
|
||||||
|
tree = html.fromstring(r.content)
|
||||||
|
|
||||||
|
try:
|
||||||
|
title = tree.xpath(('/html/body/article/p[1]')[0])
|
||||||
|
# if isinstance(title, list):
|
||||||
|
# title = title[0]
|
||||||
|
# title = str(title)
|
||||||
|
# for r in (("u'", ""), ("['", ""), ("[", ""), ("']", ""), ("\\n", ""), ("\\t", "")):
|
||||||
|
# title = title.replace(*r)
|
||||||
|
# title = unicode_string_cleanup(title)
|
||||||
|
except Exception as e:
|
||||||
|
title = None
|
||||||
|
if title:
|
||||||
|
return title
|
||||||
|
else:
|
||||||
|
return "An Error Occured"
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
page = etree.HTML(r.content)
|
page = etree.HTML(r.content)
|
||||||
title = bleach.clean(etree.tostring(page.xpath('/html/body/article/h1[1]')[0]), tags=[], strip=True)
|
title = bleach.clean(etree.tostring(page.xpath('/html/body/article/h1[1]')[0]), tags=[], strip=True)
|
||||||
summary = bleach.clean(
|
summary = bleach.clean(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user