Giter VIP home page Giter VIP logo

gurugaurav / bing_image_downloader Goto Github PK

View Code? Open in Web Editor NEW
183.0 2.0 94.0 36 KB

Python library to download bulk of images from Bing.com

Home Page: https://pypi.org/project/bing-image-downloader/

License: MIT License

Python 100.00%
bing-image-downloader image-downloader image-downloader-python image-scraper image-scrapping bing-image-scrapping python-image-webcrawler python-imagesearch python-image-download python-image-downloader

bing_image_downloader's Introduction

GitHub top language GitHub Hits

Bing Image Downloader


Python library to download bulk of images form Bing.com. This package uses async url, which makes it very fast while downloading.

Disclaimer

This program lets you download tons of images from Bing. Please do not download or use any image that violates its copyright terms.

Installation

pip install bing-image-downloader

or

git clone https://github.com/gurugaurav/bing_image_downloader
cd bing_image_downloader
pip install .

Usage

from bing_image_downloader import downloader
downloader.download(query_string, limit=100,  output_dir='dataset', adult_filter_off=True, force_replace=False, timeout=60, verbose=True)

query_string : String to be searched.
limit : (optional, default is 100) Number of images to download.
output_dir : (optional, default is 'dataset') Name of output dir.
adult_filter_off : (optional, default is True) Enable of disable adult filteration.
force_replace : (optional, default is False) Delete folder if present and start a fresh download.
timeout : (optional, default is 60) timeout for connection in seconds.
filter : (optional, default is "") filter, choose from [line, photo, clipart, gif, transparent]
verbose : (optional, default is True) Enable downloaded message.

You can also test the programm by runnning test.py keyword

PyPi

https://pypi.org/project/bing-image-downloader/


Donate

You can buy me a coffee if this project was helpful to you.

Show your support

bing_image_downloader's People

Contributors

charleslf2 avatar eugene-lam avatar gurugaurav avatar sid7631 avatar steenstra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bing_image_downloader's Issues

Image options

Could you please add the option to choose image resolution and format?

Worked fine yesterday, but showing error for me today.

I've tried this yesterday with a couple of queries and it worked completely fine. But today it is showing some error -

Traceback (most recent call last):
  File "E:\Pyhon\bing.py", line 1, in <module>
    from bing_image_downloader import downloader
  File "C:\Users\Admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\bing_image_downloader\downloader.py", line 6, in <module>
    from bing import Bing
  File "E:\Pyhon\bing.py", line 2, in <module>
    downloader.download('apricot', limit=100,  output_dir='dataset', adult_filter_off=True, force_replace=False, timeout=60, verbose=True)
AttributeError: partially initialized module 'bing_image_downloader.downloader' has no attribute 'download' (most likely due to a circular import)

Process finished with exit code 1

Duplicate Images

I am trying to create a food dataset. However, when I try to scrape from Bing using this library, I am getting a lot of duplicate images. Please assist.

Thank you

Not working anymore

Hello,
I have been using the python package for months without problems, but for a few weeks the downloaded images have no relation to the search tag and the downloads are repeated cyclically.

I mean if i search for example "box" and try to download 50 images. There are many images that are not related to boxes, and every 8 images they repeat.

ImportError

Hi, if I use bing.py and downloader.py outside the package they work perfectly. But if I import as it is in the instructions it generates ImportError: cannot import name downloader from partially initialized module bing_image_downloader.

Photo search with txt list

Congratulations on your script! it works very well!
For a project I would have to search 50 photos for a long list of plants and flowers, how can I search for photos using a txt list or similar?
Thanks and Merry Christmas!

Broken, results do not resemble same query via web

E.g.: people wearing masks in public -> lots of Donald Trump images
Results as expected when used on the website image search.

Any query seems to result in repeating images too.
This lib is currently broken and not fit for purpose.

Search food, but download many menu images

I attempted to download pizza images and used codes:
downloader.download("pizza", limit=100, output_dir="photos", adult_filter_off=True, force_replace=False, timeout=5)

However, the downloader gave me many menu images from zmenu.com.

During handling of the above exception, another exception occurred:

Do you know how to fix this error?

I was hoping to download 50k images but only 7000 images got downloaded.

[!!]Indexing page: 56

Traceback (most recent call last):
  File "/home/mona/anaconda3/lib/python3.7/urllib/request.py", line 1319, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/home/mona/anaconda3/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/mona/anaconda3/lib/python3.7/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/home/mona/anaconda3/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/mona/anaconda3/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/home/mona/anaconda3/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/home/mona/anaconda3/lib/python3.7/http/client.py", line 1414, in connect
    super().connect()
  File "/home/mona/anaconda3/lib/python3.7/http/client.py", line 938, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/home/mona/anaconda3/lib/python3.7/socket.py", line 707, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/home/mona/anaconda3/lib/python3.7/socket.py", line 752, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "download_images_from_bing.py", line 2, in <module>
    downloader.download('gun', limit=50000, adult_filter_off=True, force_replace=False)
  File "/home/mona/anaconda3/lib/python3.7/site-packages/bing_image_downloader/downloader.py", line 34, in download
    Bing().bing(query, limit, adult)
  File "/home/mona/anaconda3/lib/python3.7/site-packages/bing_image_downloader/bing.py", line 63, in bing
    response = urllib.request.urlopen(request)
  File "/home/mona/anaconda3/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/home/mona/anaconda3/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/home/mona/anaconda3/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/home/mona/anaconda3/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/home/mona/anaconda3/lib/python3.7/urllib/request.py", line 1362, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/home/mona/anaconda3/lib/python3.7/urllib/request.py", line 1321, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>

from bing_image_downloader import downloader
downloader.download('cat', limit=50000, adult_filter_off=True, force_replace=False)

It simply hangs

Hello,

I just keep getting the messages:

[!!]Indexing page: 320

[%] Indexed 10 Images on Page 320.

Any solution?

Error:: 'ascii' codec can't encode character '\xf1' in position 46: ordinal not in range(128)

've tried this yesterday with a couple of queries and it worked completely regulary. But today it is showing some error -

[%] Downloading Image #4 from http://www.zacatecasalminuto.com/wp-content/uploads/2020/05/cierra_mina_peñoles_morelos_zac.png
[!] Issue getting: http://www.zacatecasalminuto.com/wp-content/uploads/2020/05/cierra_mina_peñoles_morelos_zac.png
[!] Error:: 'ascii' codec can't encode character '\xf1' in position 46: ordinal not in range(128)

Why quotation marks do not work?

Hi
This is my code

from bing_image_downloader import downloader

query_string = 'langeek dictionary definition "Go"'
downloader.download(query_string, limit=3,  output_dir='dataset', adult_filter_off=True, 
                    force_replace=False, timeout=60, verbose=True)

But the quotation marks do not work and the results with Bing isn't same.

Error:: URL can't contain control characters. (found at least ' ')

When using the download() function, I came accross multiple control character errors. This is caused by a url containing a blank space.

I temporarily solved it by changing these two lines to replace " " with "%20" inside bing.py:
self.seen.add(link.replace(" ", "%20"))
self.download_image(link.replace(" ", "%20"))

Typo error in the documentation page on pypi.org

There was a typo when you are writing the function of the adult_filter_off parameter on the pypi.org website, you wrote (Enable for disable adult filteration) instead of (Enable or disable adult filteration).

Path problems

Hello!, when I put a destination folder the script tries to generate a folder with the name of the path I indicated, for example if I put in path "C:" it doesn't locate the images in that path but tries to create a folder called C:\ which generates an error, is there a way to solve this?

Is there also a way to rename the downloaded file and not generate a folder with the name of each search but keep them all in the same folder?

Thank you very much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.