1

Hello everyone !

I spend few weeks developping an application for IOS using Xcode in swift.

After few hours of search I couldn't find a simple way to copy an URL from google image.

This is what my application do (or what I want to do)

  • I open a Webview controller, I automaticaly find a google image webpage using some custom keyword define by the user. = working

  • When the browser is open, I just want to click (press and hold) on an image from google image and copy the image url (then I go back to my application to display it) = not working

There is a way without using Google custom search API ? If the simple way is to use this api, can I using it if it's not only for personnal use ?

Thank you for your answer !

https://i.stack.imgur.com/U0Qbo.png

From this screenshot, I want the url of the picture the user clicked on

Sam
  • 283
  • 3
  • 12
  • Hi! So basically you have a working WKWebView, which opens the image and **then** you press and hold on the image itself or the url, which you display in some UITextField like a browser? – tech4242 Aug 25 '16 at 17:52
  • Hi and thank you for your answer. Maybe with the screenshot you will understand more easily. My app go automatically on google image and I want the user to choose one of the image. Then I want the url of the image choose by the user. – Sam Aug 25 '16 at 22:42

1 Answers1

0

First of all thanks for your comment. I tried things out in one of my WKWebViews with the following result (long press on image):

http://images.google.de/imgres?imgurl=https://upload.wikimedia.org/wikipedia/commons/3/36/2015_Audi_R8_Coup%2525C3%2525A9_5.2_FSI_quattro_(19409896583).jpg&imgrefurl=https://en.wikipedia.org/wiki/Audi_R8&h=2015&w=3582&tbnid=OULjbl2zeIL-HM:&docid=TAzXl6wkDXY7yM&ei=g-a_V-PCLcS4Uc-1jtgN&tbm=isch

And this is one of those special google links, which shows you the website of the url in splitscreen with the tab for the image. My guess is that your WKWebView cannot open this URL and you are getting an error but you probably haven't set your WKWebViewDelegates like:

func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {...}

or

func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {...}

I think the best way forward is to customize the WKActionSheet in order to copy only the part after imgurl= to fetch just the image url

enter image description here

Community
  • 1
  • 1
tech4242
  • 2,348
  • 2
  • 23
  • 33
  • Now I'm looking to save the link and close the wkwebwiew when I long press an image. – Sam Aug 28 '16 at 20:26
  • By the way, if that can help other people : I wasn't using WKWebView at all. If I understand correctly UIWebView is kind of obsolete ! – Sam Aug 28 '16 at 20:31