fix extracting content
This commit is contained in:
parent
88143da955
commit
a78f7e72ed
@ -8,7 +8,7 @@ from django.conf import settings
|
||||
|
||||
|
||||
class URL(APIView):
|
||||
def get_title(self, url):
|
||||
def get_title(self, url: str):
|
||||
try:
|
||||
response = requests.get(url)
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
@ -17,6 +17,15 @@ class URL(APIView):
|
||||
except AttributeError:
|
||||
return None
|
||||
|
||||
def get_content(self, url: str):
|
||||
url = settings.READABILITY_HOST.rstrip(
|
||||
'/') + '/api/content/v1/parser?url=' + url
|
||||
try:
|
||||
response = requests.get(url).json()
|
||||
return response['excerpt']
|
||||
except AttributeError:
|
||||
return None
|
||||
|
||||
def post(self, request, format=None):
|
||||
url = request.GET.get('url')
|
||||
if url:
|
||||
|
Loading…
Reference in New Issue
Block a user