0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-22 14:08:23 -05:00

🛠️ fix: add & improve code to handle page handling in searx & duckduckgo

This commit is contained in:
neon_arch 2023-07-30 20:14:40 +03:00
parent 71c890ba05
commit a8791deb13
2 changed files with 5 additions and 2 deletions

View File

@ -45,7 +45,7 @@ impl SearchEngine for DuckDuckGo {
// Page number can be missing or empty string and so appropriate handling is required // Page number can be missing or empty string and so appropriate handling is required
// so that upstream server recieves valid page number. // so that upstream server recieves valid page number.
let url: String = match page { let url: String = match page {
1 => { 1 | 0 => {
format!("https://html.duckduckgo.com/html/?q={query}&s=&dc=&v=1&o=json&api=/d.js") format!("https://html.duckduckgo.com/html/?q={query}&s=&dc=&v=1&o=json&api=/d.js")
} }
_ => { _ => {

View File

@ -43,7 +43,10 @@ impl SearchEngine for Searx {
) -> Result<HashMap<String, RawSearchResult>, EngineError> { ) -> Result<HashMap<String, RawSearchResult>, EngineError> {
// Page number can be missing or empty string and so appropriate handling is required // Page number can be missing or empty string and so appropriate handling is required
// so that upstream server recieves valid page number. // so that upstream server recieves valid page number.
let url: String = format!("https://searx.work/search?q={query}&pageno={page}"); let url: String = match page {
0 | 1 => format!("https://searx.work/search?q={query}&pageno=1"),
_ => format!("https://searx.work/search?q={query}&pageno={page}"),
};
// initializing headers and adding appropriate headers. // initializing headers and adding appropriate headers.
let mut header_map = HeaderMap::new(); let mut header_map = HeaderMap::new();