headless_engine/google/
endpoints.rs1pub struct GoogleEndpoints;
3
4impl GoogleEndpoints {
5 pub fn search(query: &str) -> String {
6 format!(
7 "https://www.google.com/search?q={}",
8 urlencoding::encode(query)
9 )
10 }
11
12 pub fn web_search(query: &str) -> String {
13 format!(
14 "https://www.google.com/search?q={}&udm=14",
15 urlencoding::encode(query)
16 )
17 }
18
19 pub fn image_search(query: &str) -> String {
20 format!(
21 "https://www.google.com/search?q={}&udm=2",
22 urlencoding::encode(query)
23 )
24 }
25
26 pub fn video_search(query: &str) -> String {
27 format!(
28 "https://www.google.com/search?q={}&tbm=vid",
29 urlencoding::encode(query)
30 )
31 }
32
33 pub fn short_video_search(query: &str) -> String {
34 format!(
35 "https://www.google.com/search?q={}+shorts&tbm=vid",
36 urlencoding::encode(query)
37 )
38 }
39
40 pub fn news_search(query: &str) -> String {
41 format!(
42 "https://www.google.com/search?q={}&tbm=nws",
43 urlencoding::encode(query)
44 )
45 }
46
47 pub fn forum_search(query: &str) -> String {
48 format!(
49 "https://www.google.com/search?q={}&udm=18",
50 urlencoding::encode(query)
51 )
52 }
53
54 pub fn shopping_search(query: &str) -> String {
55 format!(
56 "https://www.google.com/search?q={}&tbm=shop",
57 urlencoding::encode(query)
58 )
59 }
60
61 pub fn product_search(query: &str) -> String {
62 format!(
63 "https://www.google.com/search?q={}&tbm=shop",
64 urlencoding::encode(query)
65 )
66 }
67
68 pub fn books_search(query: &str) -> String {
69 format!(
70 "https://www.google.com/search?q={}&tbm=bks",
71 urlencoding::encode(query)
72 )
73 }
74
75 pub fn autocomplete(query: &str) -> String {
76 format!(
77 "https://suggestqueries.google.com/complete/search?client=chrome&q={}",
78 urlencoding::encode(query)
79 )
80 }
81
82 pub fn ai_overview(query: &str) -> String {
83 format!(
84 "https://www.google.com/search?q={}",
85 urlencoding::encode(query)
86 )
87 }
88
89 pub fn ai_mode(query: &str) -> String {
90 format!(
91 "https://www.google.com/search?q={}&udm=50",
92 urlencoding::encode(query)
93 )
94 }
95
96 pub fn scholar_search(query: &str) -> String {
97 format!(
98 "https://scholar.google.com/scholar?q={}",
99 urlencoding::encode(query)
100 )
101 }
102
103 pub fn patents_search(query: &str) -> String {
104 format!(
105 "https://patents.google.com/?q={}",
106 urlencoding::encode(query)
107 )
108 }
109
110 pub fn maps_search(query: &str) -> String {
111 format!(
112 "https://www.google.com/maps/search/{}",
113 urlencoding::encode(query)
114 )
115 }
116
117 pub fn finance_quote(ticker: &str) -> String {
118 format!(
119 "https://www.google.com/finance/quote/{}",
120 urlencoding::encode(ticker)
121 )
122 }
123
124 pub fn trends_search(query: &str) -> String {
125 format!(
126 "https://trends.google.com/trends/explore?q={}",
127 urlencoding::encode(query)
128 )
129 }
130
131 pub fn flights_search(origin: &str, dest: &str) -> String {
132 format!(
133 "https://www.google.com/travel/flights?q=Flights+from+{}+to+{}",
134 urlencoding::encode(origin),
135 urlencoding::encode(dest)
136 )
137 }
138
139 pub fn hotels_search(location: &str) -> String {
140 format!(
141 "https://www.google.com/travel/hotels/{}",
142 urlencoding::encode(location)
143 )
144 }
145
146 pub fn travel_explore(destination: &str) -> String {
147 format!(
148 "https://www.google.com/travel/explore?q={}",
149 urlencoding::encode(destination)
150 )
151 }
152
153 pub fn youtube_search(query: &str) -> String {
154 format!(
155 "https://www.youtube.com/results?search_query={}",
156 urlencoding::encode(query)
157 )
158 }
159
160 pub fn youtube_shorts_search(query: &str) -> String {
161 format!(
162 "https://www.youtube.com/results?search_query={}&sp=mREBAgAL",
163 urlencoding::encode(query)
164 )
165 }
166
167 pub fn youtube_video(video_id: &str) -> String {
168 if video_id.starts_with("http") {
169 video_id.to_string()
170 } else {
171 format!(
172 "https://www.youtube.com/watch?v={}",
173 urlencoding::encode(video_id)
174 )
175 }
176 }
177
178 pub fn youtube_channel(channel: &str) -> String {
179 if channel.starts_with("http") {
180 channel.to_string()
181 } else if channel.starts_with('@') {
182 format!("https://www.youtube.com/{}", channel)
183 } else {
184 format!(
185 "https://www.youtube.com/channel/{}",
186 urlencoding::encode(channel)
187 )
188 }
189 }
190
191 pub fn youtube_playlist(playlist_id: &str) -> String {
192 if playlist_id.starts_with("http") {
193 playlist_id.to_string()
194 } else {
195 format!(
196 "https://www.youtube.com/playlist?list={}",
197 urlencoding::encode(playlist_id)
198 )
199 }
200 }
201
202 pub fn lens_visual_matches(image_url: &str) -> String {
203 format!(
204 "https://lens.google.com/uploadbyurl?url={}",
205 urlencoding::encode(image_url)
206 )
207 }
208
209 pub fn lens_exact_matches(image_url: &str) -> String {
210 format!(
211 "https://lens.google.com/uploadbyurl?url={}",
212 urlencoding::encode(image_url)
213 )
214 }
215
216 pub fn lens_products(image_url: &str) -> String {
217 format!(
218 "https://lens.google.com/uploadbyurl?url={}",
219 urlencoding::encode(image_url)
220 )
221 }
222
223 pub fn lens_about_image(image_url: &str) -> String {
224 format!(
225 "https://lens.google.com/uploadbyurl?url={}",
226 urlencoding::encode(image_url)
227 )
228 }
229}