The docs at https://github.com/acheong08/BingImageCreator/ is outdated and the repository is archived. That does not mean the library no longer works.
The main issue most will encounter is that the _U
cookie will no longer work by itself.
I apologize for the incomplete documentation despite supporting this feature all along.
You will need Cookie Editor for Chrome or for Firefox
Microsoft Edge is also preferred as Bing can sometimes discriminate.
Go to https://www.bing.com/images/create first and make sure you generate at least 1 image. Then, open up cookie editor and export your cookies as JSON.
From the command line, you can do this:
python3 -m BingImageCreator --cookie-file ./cookies.json --prompt "Cat"
And from code, you can use this:
from BingImageCreator import ImageGen
image_generator = ImageGen(
"", "",
all_cookies=cookie_json,
)
print(image_generator.get_images(your_prompt))
This should show you a list of image URLs.
You can see that I passed in 2 blank arguments. This is because the code is outdated and expects auth cookies. I will make a fork on another account to delete that.
Make sure you parse your JSON or translate it to a Python dict. You can read it from file or string, etc (I expect you know how to code Python)
That should be it.
Async class/functions are also available. Look through the code if you need it.