Saving images in the WebView as files

Post Reply
bazzvn
Posts: 2
Joined: Wednesday 22nd February 2017 11:06am

Saving images in the WebView as files

Post by bazzvn » Wednesday 05th April 2017 12:57pm

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

User avatar
jornmo
Site Admin
Posts: 120
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Saving images in the WebView as files

Post by jornmo » Wednesday 05th April 2017 2:19pm

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]

bazzvn
Posts: 2
Joined: Wednesday 22nd February 2017 11:06am

Re: Saving images in the WebView as files

Post by bazzvn » Wednesday 05th April 2017 11:09pm

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

User avatar
jornmo
Site Admin
Posts: 120
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: Saving images in the WebView as files

Post by jornmo » Thursday 06th April 2017 7:21am

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest