Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Return error

Daoud Clarkee2121d743f55
diff --git a/devdata/index-v2.tinysearch b/devdata/index-v2.tinysearch
index 490c48e..594b1e4 100644
Binary files a/devdata/index-v2.tinysearch and b/devdata/index-v2.tinysearch differ
diff --git a/mwmbl/views.py b/mwmbl/views.py
index 5107ed3..d1a406e 100644
--- a/mwmbl/views.py
+++ b/mwmbl/views.py
@@ -143,10 +143,11 @@ def add_url(request):
try:
response = requests.get(new_url, timeout=5)
- except RequestException:
- return HttpResponseBadRequest("Could not fetch URL")
+ except RequestException as e:
+ return HttpResponseBadRequest(f"Could not fetch URL: {str(e)}")
- paragraphs, title = justext_with_dom(response.content, justext.get_stoplist("English"))
+ print("Content", response.encoding)
+ paragraphs, title = justext_with_dom(response.text, justext.get_stoplist("English"))
good_paragraphs = [p for p in paragraphs if p.class_type == 'good']
extract = ' '.join([p.text for p in good_paragraphs])