Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from fatwang2:main #1

Merged
merged 16 commits into from
Apr 12, 2024
Prev Previous commit
Next Next commit
support serxng
  • Loading branch information
lizhe2004 committed Apr 7, 2024
commit 607030140e33e7d12afa03e2834234bb907a90a0
13 changes: 8 additions & 5 deletions search4all.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,11 @@ def search_with_searchapi(query: str, subscription_key: str):


def extract_url_content(url):
logger.info(url)
downloaded = trafilatura.fetch_url(url)
content = trafilatura.extract(downloaded)
logger.info(url)
logger.info(content)

logger.info(url +"______"+ content)
return {"url":url, "content":content}


Expand All @@ -399,8 +400,8 @@ def search_with_searXNG(query:str,url:str):

try:

safe_string = urllib.parse.quote_plus(":all !general " + query)
response = requests.get(url+'?q=' + safe_string + '&format=json')
safe_string = urllib.parse.quote_plus(":auto !general " + query)
response = requests.get(url+'?q=' + safe_string + '&format=json&engines=bing,google')
response.raise_for_status()
search_results = response.json()

Expand Down Expand Up @@ -428,6 +429,7 @@ def search_with_searXNG(query:str,url:str):
'site_name':site_name,
'icon_url':icon_url,
'title':name,
'name':name,
'url':url,
'snippet':snippet
})
Expand Down Expand Up @@ -459,7 +461,8 @@ def search_with_searXNG(query:str,url:str):
content_list.append(item_dict)
logger.info("URL: {}".format(url))
logger.info("=================")

if len(results)== 0 :
content_list = conv_links
return content_list
except Exception as ex:
logger.error(ex)
Expand Down