import gradio as gr import requests from bs4 import BeautifulSoup from google_img_source_search import ReverseImageSearcher def rev_im(url): image_url = 'https://i.pinimg.com/originals/c4/50/35/c450352ac6ea8645ead206721673e8fb.png' rev_img_searcher = ReverseImageSearcher() res = rev_img_searcher.search(image_url) for search_item in res: print(f'Title: {search_item.page_title}') print(f'Site: {search_item.page_url}') print(f'Img: {search_item.image_url}\n') return search_item.image_url def find_it(inp): out="" try: #url = f'https://lens.google.com/uploadbyurl?url={inp.strip("")}' url = f'https://tineye.com/search/?url={inp.strip("")}' response = requests.get(url) out=response.text if response.status_code == 200: page_content = response.text soup = BeautifulSoup(page_content, "html.parser") print(soup.prettify()) #articles = soup.find_all("div", class_="SoaBEf") #articles = soup.find_all("a") #articles = soup.find_all("article", class_="MQsxIb xTewfe R7GTQ keNKEd j7vNaf Cc0Z5d VkAdve GU7x0c JMJvke q4atFc") articles = soup.find_all("article") out = soup.prettify print (articles) except Exception as e: out = e print (e) return (out) #https://lens.google.com/uploadbyurl?url= #https://tineye.com/search/?url= #https://yandex.com/images/search?cbir_id=4330355%2FBhPd4CHqib3nxk9xOdS9pQ7899&rpt=imageview&url= with gr.Blocks() as app: with gr.Row(): with gr.Column(): inp_url=gr.Textbox(label="Image URL") go_btn=gr.Button() inp_im=gr.Image() outp_text = gr.Textbox(lines=4) go_btn.click(rev_im,inp_url,outp_text) app.launch()