Page 1 of 1

Saving images in the WebView as files

Posted: Wednesday 5th April 2017 12:57pm
by bazzvn
In Firefox, Right-Clicking on an image will usually allow one to save the image to a local file. I am trying to do the same sort of thing from web pages displayed in a Qt WebView.
It is not too difficult to extract the link to the image source from the WebView, for example, "https://www.quantamagazine.org/wp-content/uploads/2017/03/EvoHorse_1K.jpg", but I don't know how to locate or specify the path to the source file within this link so that the file can be copied to a local folder.
I would be grateful for any suggestions.
bazzvn

Re: Saving images in the WebView as files

Posted: Wednesday 5th April 2017 2:19pm
by jornmo
If you are asking how to save it? Then look at this: http://gambaswiki.org/wiki/comp/gb.net.curl/httpclient

If you are asking how to extract the filename from the URL, try this:
Dim sFileName As String
Dim sURL As String = "someURL"
sFileName = Split(sURL, "/").Reverse()[0]

Re: Saving images in the WebView as files

Posted: Wednesday 5th April 2017 11:09pm
by bazzvn
Thank you Jornmo. It was the former, how to save the file. I never thought to look at the gb.net component, but the wiki link you posted looks like it will solve my problem. Much appreciated.
bazzvn

Re: Saving images in the WebView as files

Posted: Thursday 6th April 2017 7:21am
by jornmo
You may also find that gb.xml.html:

http://gambaswiki.org/wiki/comp/gb.xml.html/

is a good alternative to the webkit component for web scraping :)

I just scraped 66 pages in 5-10 seconds here the other day with this method myself.