Spaces:
Running
Running
from bs4 import BeautifulSoup | |
import requests | |
from src.application.image.search_yandex import get_image_links | |
img_search_url = """https://yandex.ru/images/search?cbir_id=4481385%2Fw-xYJ246B9thwtVBmNcpkg9409&rpt=imageview&lr=10636""" | |
print(img_search_url) | |
headers = { | |
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36', | |
'Content-Type': 'application/json', | |
} | |
response = requests.get(img_search_url, headers=headers) | |
response.raise_for_status() # Raise an exception for bad status codes | |
# Parse the HTML content | |
soup = BeautifulSoup(response.content, 'html.parser') | |
image_urls = get_image_links(soup.prettify()) | |
print(f"image_urls: {image_urls}") | |