Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding an easter-egg in Internet with Visual Foxpro 2

Status
Not open for further replies.

german12

Programmer
Nov 12, 2001
563
DE
If I want to search for a term in Google - it's easy:
I call google and write "easter egg".
Then I get this address as an example:

and as you can see, the search term is also visible there.
(easter + egg).

Of course - I can find GOOGLE with Hyperlink1.navigateto(but thats not deep enough...

Two questions:

I don't know now whether this address could be found from VFP,
if you only had "Easter eggs" as input - or - a little more clearly:

a) Could you start with a term from VFP (in this example "Easter egg")
in order to get the above mentioned GOOGLE page which includes your term?

b) Could VFP then read and save this link?

Maybe a stupid question - but my father once said:
"There are no stupid questions, only stupid answers"
I hope my question is not a rotten egg

Happy Easter to all of you
Keep healthy


Klaus

Peace worldwide - it starts here...
 
Meanwhile I answered most of my question myself.
Question a)
Yes.
I created a form with a hyperlink object on it.
Then I added a command-button with this click-code

Code:
term1 = "[URL unfurl="true"]https://www.google.de/search?q="[/URL]     *should be a constant as I assume

term2 = "rose+"                               *1th search item
term3 ="lila"                                 *2nd search item
term4 = term1+term2+term3
thisform.Hyperlink1.navigateto(term4)         *opens the requested site.
this leads to

and I can see a rose coloured lila
Means:
All I have to do is creating a dbf with search-terms in it (may be that there is a free wordbook somewhere), and from there I can start with a listbox on a form to see
what is to be found for my search.
Never something has to be typed then.One click - one site...gg



So question b) is now another one:
can I grab the picture (that lila rose) and store it by using VFP?







Peace worldwide - it starts here...
 
I once tried to use Google's feature to say "did you mean..." to check the correct spelling of words. If you automatically search too often (ca. 1000 times) Google will deny answers. To do as many searches as you want you need to pay

That's the one side.

The other is of course you can save pictures. but automate the internet explorer, don't use the hyperlink.
Then you can also use faq184-5510 to save the whole page including a folder with the pictures of the page besides other things.

Chriss
 
Thanks Criss, this will help me much.
Thank you very much.

Chriss said:
I once tried to use Google's feature to say "did you mean..." to check the correct spelling of words. If you automatically search too often (ca. 1000 times) Google will deny answers. To do as many searches as you want you need to pay

I did not know that before.

What does that mean - 1000 times? In which range of time?
Where can I find more about that?
does google register whether someone entered the term manually or automatically?

Regards
Klaus

Peace worldwide - it starts here...
 
does google register whether someone entered the term manually or automatically?

Google is certainly clever enough to distinguish between a one-off manual search and a large number of automatic ones. And it will certainly react differently in the two cases. Since Google makes money by showing adverts on search result pages, and since such adverts are only useful to human eyes, it seems likely that the search engine would consider automatic searches unfavourably.

Whether that means a large number of searches, or a number of searches in a given period - I doubt it anyone outside Google knows; and Google is unlikely to tell us.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike, thank you very much for your considerations - I can understand them well.
When I think about it, however, I believe that Google's greatest interest could be that no one could overload the system with program-controlled access.

Mike said:
adverts are only useful to human eyes

Here one could of course argue that the information that is accessed via a machine is ultimately always intended for human eyes.

That applies to text and images - and then it would have to be an advantage for GOOGLE again.
It is also possible to start several different bookmarks in your own browser at the same time without Google refusing to answer.We won't find out what Googles strategy is - and it is not my intention to possibly annoy Google with loop programming.
What I would like to do is to have bookmarks in one form and use them to view images in GOOGLE, because then one can also put a lot of additional information in one form.
For example, a table with the Internet addresses of paintings, but also information about the artist, the painting technique, the origin, the country, etc.
I'll try it - and if Google does not allow that with normal (i.e. not excessive)use, then I'll use a different search engine - and I would also publish my experiences here.

Thanks again.
Klaus


Peace worldwide - it starts here...
 
My experience was after a number of searches google answered with a page stating too many searches. So you just don't get results after a while.
You don't have to fear to get prosecuted. I never tried again, today they might even tell you how to get more quota by using their API.

I have to second Mike on the ads. If you run your searches just saving the results of interest, you don't look at their ads, especially if you just follow the links of results. They will need to refund advertisers when thy judge your requests as bulk searching, so they won't earn from these searches.

Chriss
 
Hi Chriss and Mike, thank you for your advice on the subject of "Google".
As I already wrote, I would like to access on paintings on the Internet with a VFP form.
Now I think, because of the warnings from Mike and you, I can do that without Google and instead go directly to the URL of an artist.

Example for 2 links:

a) via Google:

b) artist's URL directly

This eliminates the risk that access to almost the same information no longer works when I try it via Google.

With this I could e.g. save the name of the artist, his painting technique (watercolor), his motifs and his URL etc. in a table and have quick access at any time.

I would like to try it with a FOR-NEXT loop to see if there are any problems, but I don't know whether - and if so, how - Visual Foxpro can close a website after a wait before NEXT comes.

Can VFP do it??


Regards from Germany
Klaus


Peace worldwide - it starts here...
 
Why a for loop?

Put your URLs into a table and do a scan..endscan loop.

And you determine when to close the webpage when you release your Internet Explorer Object. And you simply navigate to the next URL in your list to open it and at the same time close the old one, so there is no need to release IE until you navigated to the last URL you have.

I still think you got us wrong, but never mind. The first URL you have is a search request. If you already know the most relevant search result webpage, there's no need to start at Google again, is there? You only use it to discover new artists' web pages, it seems by your interest on how artists paint certain subjects.



Chriss
 
Klaus, going straight to the artist's URL seems much more sensible than searching for the artist in Google. There is no point in doing a search if you already know the URL. Also, you can't guarantee that Google will always return the artist's site at the top of its hits. It's possible that an advertiser might pay for a top listing using similar keywords to the artist's name.

Regarding using a FOR / NEXT loop, there's no reason for this not to work, although, as Chriss pointed out, you might just as well scan a table of URLs. You asked about "closing" a website. There is no concept of opening or closing a website. The website is always there. You just navigate to it, then navigate to somewhere else. (Or did I misunderstand the question?)

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi, Mike & Chriss,
Thanks for the hints.
I am afraid I have been misunderstood
I wanted to try this code;
Test program
x = 5 * what happens when x = 200 or more?

mylink = "FOR i = 1 TO x
thisform.Hyperlink1.navigateto (mylink)
WAIT WINDOW
* how to code to close that page in memory now?
ENDFOR


* to avoid overflow in memory - what has to be coded, to close the site after each call on my pc?
* As you can see from the picture attached my browser loads and loads and creates tabs...
* is there something like "Hyperlink1.close .."?

The only problem is that then - the number of tabs in my computer keeps increasing,
and so the main memory will eventually be overcrowded.

Therefore, the program should always close the last page called (I didn't want to do that by hand).

I wanted to find out what, a call via Google would do if, for example, a page was called up over and over again 200 times.
Therefore the mentioned loop - I was curious how often this works before the system replies "too many calls"
I know that I can call up different pages one after another with scan ... endscan,
I only wanted not to close it myself (e.g. marking the "X" right on top manually).
I wanted to close a website with VFP
Addition:
Imagine you want to have a dis-show of pages - but don't want to have a new tab for each called page - how to avoid this?
I hope I expressed myself better this time.

Greetings
Klaus


Peace worldwide - it starts here...
 
This is how my pc looks (see list of tabs)

2021-04-09_13_35_11-Abigail_Gutting_Fine_Art_a5zwu3.png


Peace worldwide - it starts here...
 
If I've understood this right, when you say you want to "close the website", what you really want to do is to close the browser tab. (As I mentioned earlier, there is no concept of opening or closing websites.)

I don't know of any way of closing a tab programmatically with the Hyperlink object, because you don't have an object reference to the browser (as far as I know). But I wonder if there is a setting in the browser to tell it to use the same tab for each URL request? Alternatively, I think there is a setting within Google where you can tell it to open the target URL in the same tab as the search results. Maybe that will solve the problem?

UPDATE:
In Google Search settings, there is an option labelled "Open each selected result in a new browser window". I wonder if switching that option off would help solve the problem.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike
You are right, i tried serveral things, but failed.
The only way is indeed to change something in the browser.

In my browser (FIREFOX) this can be done in the settings.
The default there is :
"open the link in tabs instead of in new windows" -
that is normally ok, as you can see what has been done etc.

By removing the cross in that setting FIREFOX shows always only one Homepage.
I tested it with my loop and always the same URL.

I am happy that I have learned something again.

Best regards
Klaus


Peace worldwide - it starts here...
 
Klaus,

You mentioned the setting in Firefox. However, when you call Navigate2 for a Hyperlink object, it always invokes Internet Explorer (or whatever we are supposed to call it these days). So changing a setting in Firefox won't make any difference.

However, Internet Explorer has a setting: Tools -> Internet Options -> General tab -> Tabs button. Under "Open links from other programs in:", there is an option, "The current tab or window". I don't know how useful that would be, but it might be worth experimenting.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,
I think you mean by "Internet Explorer" the same thing that Microsoft delivers today as "Microsoft Edge" together with the Windows 10 operating system.
Internet Explorer existed until 2015 - but then it became MS Edge, which is now based on Chromium. Just like it is the case with Google's Chrome browser.
Chromium is open-source - and so is Firefox.

I never used MS Browsers - although MS Edge is as fast as Firefox is.
But MS is a for-profit company - and Mozilla is not - maybe that's the reason - and of course getting used to Firefox, which saves me from switching.

However, I looked up what you wrote
Mike said:
Tools -> Internet Options -> General tab -> Tabs button. Under "Open links from other programs in:", there is an option, "The current tab or window".
but unfortunately I didn't find it in the Edge settings.

Greetings from Germany (near the dutch border)
Klaus


Peace worldwide - it starts here...
 
Klaus, of course you are right about Edge having replaced Internet Explorer in Windows 10. But that doesn't affect the options that I mentioned. Confusingly, in all versions of Windows, the relevant settings are known as Internet Options, even though they relate almost exclusively to the browser rather than the Internet in general.

In fact, I think that Internet Explorer is still present behind the scenes in Windows 10 (not sure about that). But in any case the settings I mentioned are definitely still there, and can be reached via Control Panel.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I still think automating IE is the simplest. It's still a separate browser and my Win10 has IE version 20H2 according to the info.

You can find out all img links to jpg,png, or other images with this:

Code:
GetPictures('[URL unfurl="true"]www.tek-tips.com')[/URL]

Function GetPictures(tcURL)
   Local loIE
   
   loIE = CreateObject('InternetExplorer.Application')
   loIE.navigate2(tcURL)
   
   Do While loIE.readystate<4
      Doevents
   EndDo 
   
   loBody = loIE.document.body
   loImages = loBody.getElementsByTagName('img')
   
   For Each loImage in loImages
      ? loImage.alt, loImage.src
   EndFor
EndFunc

Chriss
 
Thanks Chriss and Mike.
I still try to find out, why I cannot run the program above.

Chriss:
When I run your program I receive

Error said:
Class definition "name" is not found (Error 1733)

Pops up for program-line: loIE = CreateObject('InternetExplorer.Application')


Mike

As I could see on your screenshot (and I hope I am not wrong with this) these settings were made for the Internet-Explorer (which I have not on my system, but only MS EDGE - and there is no TAB setting like in your screenshot)
I tried to download IE, but obviously this is not possible anymore.
Does that mean, that Chriss' code will not run on systems where people have no Internet-Explorer on board?

Maybe that all my thoughts are completely wrong.
I hope that it is the case.

Regards
Klaus


Peace worldwide - it starts here...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top