Google Image Scraper.
Project description
Google-Image-Scraper
About
This module is based on web-scraping technology and uses Google Images to provide a Streamable Image API.
Supported Browsers
- Chrome
How to Use?
# import Scraper class
from gi_scraper import Scraper
# Pass a Cache instance with a custom directory path and timeout
# Set cache timeout to -1 for caching indefinitely
"""
from gi_scraper import Cache
cache = Cache(dir_path="gi_cache", timeout=-1)
sc = Scraper(workers=8, headless=False, cache=cache)
"""
# The object creation has an overhead time
# The same object can be reused to fire multiple queries
sc = Scraper(headless=False)
for query, count in {"Naruto": 20, "Gintoki": 30}.items():
print("Scraping...", query, ":", count)
# scrape method returns a stream object
stream = sc.scrape(query, count)
# stream.get method yields Response object with following attributes
# - query (str): The query associated with the response.
# - name (str): The name attribute of the response.
# - src_name (str): The source name attribute of the response.
# - src_page (str): The source page attribute of the response.
# - thumbnail (str): The thumbnail attribute of the response.
# - image (str): The image attribute of the response.
# - width (int): The width attribute of the response.
# - height (int): The height attribute of the response.
for index, response in enumerate(stream.get()):
if index == 10:
sc.terminate_query() # Terminate current query midway
break
# response.to_dict returns python representable dictionary
print(response.width, "x", response.height, ":", response.image)
# call this to terminate scraping (auto-called by destructor)
sc.terminate()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gi_scraper-0.4.6.tar.gz
(9.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gi_scraper-0.4.6.tar.gz.
File metadata
- Download URL: gi_scraper-0.4.6.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8351dfe076c1346c66b1d4271fafc4912bc9ff008f9ce190043440b5e3e336f
|
|
| MD5 |
35f6bfbe75ada73f7732d7da55e87dc5
|
|
| BLAKE2b-256 |
1d039333737254bda8f9b45a5c405630828cef30288574d07b1ffb539ee1ab48
|
File details
Details for the file gi_scraper-0.4.6-py3-none-any.whl.
File metadata
- Download URL: gi_scraper-0.4.6-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67f42deb3b5b4898c2169e11a98416322eaff626b3931432a046aa072d519bba
|
|
| MD5 |
318d088fbd05da23c5439b41666c8d70
|
|
| BLAKE2b-256 |
c862e1928081d14a1b8539ca236c28b5e020f69217656b3e2006346b184b19c4
|