<jupyter_start><jupyter_text>bing image search- https://azure.microsoft.com/ja-jp/services/cognitive-services/bing-image-search-api/- https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-images-api-v7-referencequery-parameters<jupyter_code>import requests
with open("../../.credentials/bing_key.txt") as f:
    subscription_key = f.read().replace('\n','')
search_url = "https://api.cognitive.microsoft.com/bing/v7.0/images/search"
search_term = "<PASSWORD>"
# search_term = "だし巻き玉子"
headers = {"Ocp-Apim-Subscription-Key" : subscription_key}
def get_bing_images(url, headers, term):
    params  = {"q": term,  "mkt": "ja-JP", "count": 150}
    response = requests.get(url, headers=headers, params=params)
    return response.json()
search_results = get_bing_images(search_url, headers, search_term)
values = search_results.get('value')
def download_image(value):
    url = value.get('contentUrl')
    response = requests.get(url)
    return response.content
def save_image(filename, image):
    with open(filename, 'wb') as f:
        f.write(image)
dir_path = 'tamagoyaki'
for i, value in enumerate(values):
    image = download_image(value)
    filename = "../../images/raw/{0}/tamagoyaki_{1:04d}.{2}".format(dir_path, i, values[0].get('encodingFormat'))
    save_image(filename, image)
    if (i+1)%10 == 0:
        print(f"{i+1}-images created.")
print("DONE")<jupyter_output>DONE
{'fraction_non_alphanumeric': 0.16905444126074498, 'fraction_numerical': 0.012177650429799427, 'mean_word_length': 4.748971193415638, 'pattern_counts': {'":': 3, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '60445', 'license': 'Apache-2.0', 'n_tokens_mistral': 502, 'n_tokens_neox': 490, 'n_words': 82, 'path': 'data_collection/bing_crawler/crawling.ipynb', 'repo_name': 'tohtsky/tamagoyaki', 'size': '1390'}