alamin655 commited on
Commit
ddb10f6
·
unverified ·
2 Parent(s): 41f3fe7 61393ba

Merge pull request #469 from neon-mmd/FIX/468_pagination-for-the-upstream-search-engines-not-working

Browse files
Cargo.lock CHANGED
@@ -79,7 +79,7 @@ dependencies = [
79
  "actix-rt",
80
  "actix-service",
81
  "actix-utils",
82
- "ahash 0.8.6",
83
  "base64 0.21.5",
84
  "bitflags 2.4.1",
85
  "bytes 1.5.0",
@@ -190,7 +190,7 @@ dependencies = [
190
  "actix-service",
191
  "actix-utils",
192
  "actix-web-codegen",
193
- "ahash 0.8.6",
194
  "bytes 1.5.0",
195
  "bytestring",
196
  "cfg-if 1.0.0",
@@ -255,9 +255,9 @@ dependencies = [
255
 
256
  [[package]]
257
  name = "ahash"
258
- version = "0.8.6"
259
  source = "registry+https://github.com/rust-lang/crates.io-index"
260
- checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a"
261
  dependencies = [
262
  "cfg-if 1.0.0",
263
  "getrandom",
@@ -489,9 +489,9 @@ dependencies = [
489
 
490
  [[package]]
491
  name = "bstr"
492
- version = "1.8.0"
493
  source = "registry+https://github.com/rust-lang/crates.io-index"
494
- checksum = "542f33a8835a0884b006a0c3df3dadd99c0c3f296ed26c2fdc8028e01ad6230c"
495
  dependencies = [
496
  "memchr",
497
  "serde",
@@ -637,18 +637,18 @@ dependencies = [
637
 
638
  [[package]]
639
  name = "clap"
640
- version = "4.4.11"
641
  source = "registry+https://github.com/rust-lang/crates.io-index"
642
- checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2"
643
  dependencies = [
644
  "clap_builder",
645
  ]
646
 
647
  [[package]]
648
  name = "clap_builder"
649
- version = "4.4.11"
650
  source = "registry+https://github.com/rust-lang/crates.io-index"
651
- checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb"
652
  dependencies = [
653
  "anstyle",
654
  "clap_lex",
@@ -1459,7 +1459,7 @@ version = "0.13.2"
1459
  source = "registry+https://github.com/rust-lang/crates.io-index"
1460
  checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
1461
  dependencies = [
1462
- "ahash 0.8.6",
1463
  "bumpalo",
1464
  ]
1465
 
@@ -1973,9 +1973,9 @@ checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
1973
 
1974
  [[package]]
1975
  name = "memchr"
1976
- version = "2.6.4"
1977
  source = "registry+https://github.com/rust-lang/crates.io-index"
1978
- checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
1979
 
1980
  [[package]]
1981
  name = "memoffset"
@@ -3066,7 +3066,7 @@ version = "0.18.1"
3066
  source = "registry+https://github.com/rust-lang/crates.io-index"
3067
  checksum = "585480e3719b311b78a573db1c9d9c4c1f8010c2dee4cc59c2efe58ea4dbc3e1"
3068
  dependencies = [
3069
- "ahash 0.8.6",
3070
  "cssparser 0.31.2",
3071
  "ego-tree",
3072
  "html5ever 0.26.0",
@@ -4056,7 +4056,7 @@ checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10"
4056
 
4057
  [[package]]
4058
  name = "websurfx"
4059
- version = "1.6.11"
4060
  dependencies = [
4061
  "actix-cors",
4062
  "actix-files",
 
79
  "actix-rt",
80
  "actix-service",
81
  "actix-utils",
82
+ "ahash 0.8.7",
83
  "base64 0.21.5",
84
  "bitflags 2.4.1",
85
  "bytes 1.5.0",
 
190
  "actix-service",
191
  "actix-utils",
192
  "actix-web-codegen",
193
+ "ahash 0.8.7",
194
  "bytes 1.5.0",
195
  "bytestring",
196
  "cfg-if 1.0.0",
 
255
 
256
  [[package]]
257
  name = "ahash"
258
+ version = "0.8.7"
259
  source = "registry+https://github.com/rust-lang/crates.io-index"
260
+ checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01"
261
  dependencies = [
262
  "cfg-if 1.0.0",
263
  "getrandom",
 
489
 
490
  [[package]]
491
  name = "bstr"
492
+ version = "1.9.0"
493
  source = "registry+https://github.com/rust-lang/crates.io-index"
494
+ checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc"
495
  dependencies = [
496
  "memchr",
497
  "serde",
 
637
 
638
  [[package]]
639
  name = "clap"
640
+ version = "4.4.12"
641
  source = "registry+https://github.com/rust-lang/crates.io-index"
642
+ checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d"
643
  dependencies = [
644
  "clap_builder",
645
  ]
646
 
647
  [[package]]
648
  name = "clap_builder"
649
+ version = "4.4.12"
650
  source = "registry+https://github.com/rust-lang/crates.io-index"
651
+ checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9"
652
  dependencies = [
653
  "anstyle",
654
  "clap_lex",
 
1459
  source = "registry+https://github.com/rust-lang/crates.io-index"
1460
  checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
1461
  dependencies = [
1462
+ "ahash 0.8.7",
1463
  "bumpalo",
1464
  ]
1465
 
 
1973
 
1974
  [[package]]
1975
  name = "memchr"
1976
+ version = "2.7.1"
1977
  source = "registry+https://github.com/rust-lang/crates.io-index"
1978
+ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
1979
 
1980
  [[package]]
1981
  name = "memoffset"
 
3066
  source = "registry+https://github.com/rust-lang/crates.io-index"
3067
  checksum = "585480e3719b311b78a573db1c9d9c4c1f8010c2dee4cc59c2efe58ea4dbc3e1"
3068
  dependencies = [
3069
+ "ahash 0.8.7",
3070
  "cssparser 0.31.2",
3071
  "ego-tree",
3072
  "html5ever 0.26.0",
 
4056
 
4057
  [[package]]
4058
  name = "websurfx"
4059
+ version = "1.7.3"
4060
  dependencies = [
4061
  "actix-cors",
4062
  "actix-files",
Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
  [package]
2
  name = "websurfx"
3
- version = "1.6.11"
4
  edition = "2021"
5
  description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind."
6
  repository = "https://github.com/neon-mmd/websurfx"
 
1
  [package]
2
  name = "websurfx"
3
+ version = "1.7.3"
4
  edition = "2021"
5
  description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind."
6
  repository = "https://github.com/neon-mmd/websurfx"
src/engines/duckduckgo.rs CHANGED
@@ -51,15 +51,14 @@ impl SearchEngine for DuckDuckGo {
51
  // Page number can be missing or empty string and so appropriate handling is required
52
  // so that upstream server recieves valid page number.
53
  let url: String = match page {
54
- 1 | 0 => {
55
  format!("https://html.duckduckgo.com/html/?q={query}&s=&dc=&v=1&o=json&api=/d.js")
56
  }
57
  _ => {
58
  format!(
59
- "https://duckduckgo.com/html/?q={}&s={}&dc={}&v=1&o=json&api=/d.js",
60
- query,
61
- (page / 2 + (page % 2)) * 30,
62
- (page / 2 + (page % 2)) * 30 + 1
63
  )
64
  }
65
  };
 
51
  // Page number can be missing or empty string and so appropriate handling is required
52
  // so that upstream server recieves valid page number.
53
  let url: String = match page {
54
+ 0 => {
55
  format!("https://html.duckduckgo.com/html/?q={query}&s=&dc=&v=1&o=json&api=/d.js")
56
  }
57
  _ => {
58
  format!(
59
+ "https://duckduckgo.com/html/?q={query}&s={}&dc={}&v=1&o=json&api=/d.js",
60
+ page * 30,
61
+ page * 30 + 1
 
62
  )
63
  }
64
  };
src/engines/librex.rs CHANGED
@@ -65,17 +65,10 @@ impl SearchEngine for LibreX {
65
  ) -> Result<HashMap<String, SearchResult>, EngineError> {
66
  // Page number can be missing or empty string and so appropriate handling is required
67
  // so that upstream server recieves valid page number.
68
- let url: String = match page {
69
- 1 | 0 => {
70
- format!("https://search.ahwx.org/search.php?q={query}&p=0&t=10")
71
- }
72
- _ => {
73
- format!(
74
- "https://search.ahwx.org/search.php?q={query}&p={}&t=10",
75
- page * 10,
76
- )
77
- }
78
- };
79
 
80
  // initializing HeaderMap and adding appropriate headers.
81
  let header_map = HeaderMap::try_from(&HashMap::from([
 
65
  ) -> Result<HashMap<String, SearchResult>, EngineError> {
66
  // Page number can be missing or empty string and so appropriate handling is required
67
  // so that upstream server recieves valid page number.
68
+ let url: String = format!(
69
+ "https://search.ahwx.org/search.php?q={query}&p={}&t=10",
70
+ page * 10
71
+ );
 
 
 
 
 
 
 
72
 
73
  // initializing HeaderMap and adding appropriate headers.
74
  let header_map = HeaderMap::try_from(&HashMap::from([
src/engines/searx.rs CHANGED
@@ -50,14 +50,10 @@ impl SearchEngine for Searx {
50
  safe_search = 2;
51
  };
52
 
53
- let url: String = match page {
54
- 0 | 1 => {
55
- format!("https://searx.be/search?q={query}&pageno=1&safesearch={safe_search}")
56
- }
57
- _ => {
58
- format!("https://searx.be/search?q={query}&pageno={page}&safesearch={safe_search}")
59
- }
60
- };
61
 
62
  // initializing headers and adding appropriate headers.
63
  let header_map = HeaderMap::try_from(&HashMap::from([
 
50
  safe_search = 2;
51
  };
52
 
53
+ let url: String = format!(
54
+ "https://searx.be/search?q={query}&pageno={}&safesearch={safe_search}",
55
+ page + 1
56
+ );
 
 
 
 
57
 
58
  // initializing headers and adding appropriate headers.
59
  let header_map = HeaderMap::try_from(&HashMap::from([
src/engines/startpage.rs CHANGED
@@ -50,17 +50,10 @@ impl SearchEngine for Startpage {
50
  ) -> Result<HashMap<String, SearchResult>, EngineError> {
51
  // Page number can be missing or empty string and so appropriate handling is required
52
  // so that upstream server recieves valid page number.
53
- let url: String = match page {
54
- 1 | 0 => {
55
- format!("https://startpage.com/do/dsearch?q={query}&num=10&start=0")
56
- }
57
- _ => {
58
- format!(
59
- "https://startpage.com/do/dsearch?q={query}&num=10&start={}",
60
- page * 10,
61
- )
62
- }
63
- };
64
 
65
  // initializing HeaderMap and adding appropriate headers.
66
  let header_map = HeaderMap::try_from(&HashMap::from([
 
50
  ) -> Result<HashMap<String, SearchResult>, EngineError> {
51
  // Page number can be missing or empty string and so appropriate handling is required
52
  // so that upstream server recieves valid page number.
53
+ let url: String = format!(
54
+ "https://startpage.com/do/dsearch?q={query}&num=10&start={}",
55
+ page * 10,
56
+ );
 
 
 
 
 
 
 
57
 
58
  // initializing HeaderMap and adding appropriate headers.
59
  let header_map = HeaderMap::try_from(&HashMap::from([