Google Lens
Classes
GoogleLensBaseItem
Bases: BaseSearchItem
Base class for Google Lens items with common image extraction functionality.
Source code in PicImageSearch/model/google_lens.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
Attributes
base64_image_map = base64_image_map
instance-attribute
image_url_map = image_url_map
instance-attribute
Functions
__init__(data, image_url_map, base64_image_map, **kwargs)
Initializes a GoogleLensBaseItem with data and image maps.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
PyQuery
|
PyQuery object containing the item data |
required |
image_url_map
|
dict[str, str]
|
Dictionary mapping image IDs to URLs |
required |
base64_image_map
|
dict[str, str]
|
Dictionary mapping image IDs to base64 data |
required |
**kwargs
|
Any
|
Additional keyword arguments |
{}
|
Source code in PicImageSearch/model/google_lens.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
GoogleLensExactMatchesItem
Bases: GoogleLensBaseItem
Represents a single Google Lens exact match item.
Attributes:
Name | Type | Description |
---|---|---|
origin |
PyQuery
|
The raw PyQuery object of the search result item. |
url |
str
|
URL of the webpage containing the exact match. |
title |
str
|
Title of the exact match result. |
site_name |
str
|
Name of the site where the exact match is found. |
size |
Optional[str]
|
Size information of the product, if applicable. |
thumbnail |
str
|
URL of the image representing the exact match. |
Source code in PicImageSearch/model/google_lens.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
Functions
__init__(data, image_url_map, base64_image_map, **kwargs)
Initializes a GoogleLensExactMatchesItem with data from a search result.
Source code in PicImageSearch/model/google_lens.py
312 313 314 315 316 317 318 319 320 |
|
GoogleLensExactMatchesResponse
Bases: BaseSearchResponse[GoogleLensExactMatchesItem]
Represents a complete Google Lens exact matches search response.
Attributes:
Name | Type | Description |
---|---|---|
origin |
PyQuery
|
The raw PyQuery object of the entire response page. |
raw |
list[GoogleLensExactMatchesItem]
|
List of GoogleLensExactMatchesItem objects representing exact matches. |
url |
str
|
URL of the search results page. |
Source code in PicImageSearch/model/google_lens.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
|
Functions
__init__(resp_data, resp_url, **kwargs)
Initializes GoogleLensExactMatchesResponse with HTML response data.
Source code in PicImageSearch/model/google_lens.py
352 353 354 |
|
GoogleLensItem
Bases: GoogleLensBaseItem
Represents a single Google Lens visual match item.
Attributes:
Name | Type | Description |
---|---|---|
origin |
PyQuery
|
The raw PyQuery object of the search result item. |
url |
str
|
URL of the webpage containing the visual match. |
title |
str
|
Title of the visual match result. |
site_name |
str
|
Name of the site where the visual match is found. |
thumbnail |
str
|
URL of the image representing the visual match. |
Source code in PicImageSearch/model/google_lens.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
Functions
__init__(data, image_url_map, base64_image_map, **kwargs)
Initializes a GoogleLensItem with data from a search result.
Source code in PicImageSearch/model/google_lens.py
180 181 182 183 184 185 186 187 188 |
|
GoogleLensRelatedSearchItem
Bases: GoogleLensBaseItem
Represents a single Google Lens related search item.
Attributes:
Name | Type | Description |
---|---|---|
origin |
PyQuery
|
The raw PyQuery object of the related search item. |
url |
Optional[str]
|
URL for the related search. |
title |
str
|
Title of the related search suggestion. |
thumbnail |
str
|
URL of the image associated with the related search. |
Source code in PicImageSearch/model/google_lens.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
Functions
__init__(data, image_url_map, base64_image_map, **kwargs)
Initializes a GoogleLensRelatedSearchItem with data from a related search result.
Source code in PicImageSearch/model/google_lens.py
219 220 221 222 223 224 225 226 227 |
|
GoogleLensResponse
Bases: BaseSearchResponse[GoogleLensItem]
Represents a complete Google Lens search response (for 'all', 'products', 'visual_matches' types).
Attributes:
Name | Type | Description |
---|---|---|
origin |
PyQuery
|
The raw PyQuery object of the entire response page. |
raw |
list[GoogleLensItem]
|
List of GoogleLensItem objects representing visual matches. |
related_searches |
list[GoogleLensRelatedSearchItem]
|
List of related search suggestions. |
url |
str
|
URL of the search results page. |
Source code in PicImageSearch/model/google_lens.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
|
Functions
__init__(resp_data, resp_url, **kwargs)
Initializes a GoogleLensResponse with the HTML response data.
Source code in PicImageSearch/model/google_lens.py
252 253 254 |
|
Functions
extract_base64_images(script_text, base64_image_map)
Extract Base64 encoded images from script.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
script_text
|
str
|
The JavaScript content to parse |
required |
base64_image_map
|
dict[str, str]
|
Dictionary to store extracted base64 image data |
required |
Source code in PicImageSearch/model/google_lens.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
extract_image_maps(html)
Extract image mapping information from HTML.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
html
|
PyQuery
|
PyQuery object containing the page HTML |
required |
Returns:
Type | Description |
---|---|
tuple[dict[str, str], dict[str, str]]
|
tuple[dict[str, str], dict[str, str]]: A tuple containing (image_url_map, base64_image_map) |
Source code in PicImageSearch/model/google_lens.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
extract_ldi_images(script_text, image_url_map)
Extract LDI image URLs from script.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
script_text
|
str
|
The JavaScript content to parse |
required |
image_url_map
|
dict[str, str]
|
Dictionary to store extracted image URLs |
required |
Source code in PicImageSearch/model/google_lens.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
get_site_name(url)
Extracts the site name from a URL.
Source code in PicImageSearch/model/google_lens.py
13 14 15 16 17 18 19 |
|
parse_image_size(html)
Parses the image size from the HTML snippet.
Source code in PicImageSearch/model/google_lens.py
22 23 24 25 26 27 28 29 30 31 |
|