hartmut Posted July 9, 2007 Posted July 9, 2007 I would like to automate the retrival of some text in my web viewer. The problem is how to get to it. When I hit the tab on the keyboard it moves to the web viewer and then if I do a select all and copy I can get the text and dump it into a field. Is there any way to script this .
Asda Posted July 9, 2007 Posted July 9, 2007 Have you tried the function: getLayoutObjectAttribute. It gives you the html code, you will then have to parse out the text required. Quite complicated and maybe overkill for your situation. Others may have better ideas.
fabriceN Posted July 9, 2007 Posted July 9, 2007 Not that complicated, if you have a good HTML parser custom function. You will find several on Brian Dunning's website.
hartmut Posted July 9, 2007 Author Posted July 9, 2007 Thank you. I am looking. I have problems finding a custom function or something that addresses the web viewer and not a regular field. If I could do this I would solve a lot of problems with my project. The web viewer has one line of text in it each time.
fabriceN Posted July 9, 2007 Posted July 9, 2007 That's what Asda's reply was about. Instead of storing the HTML code in a field, use GetLayoutObjectAttribute ( "yourWVname" ; "content" ) and pass this calculation to one of the custom functions.
hartmut Posted July 9, 2007 Author Posted July 9, 2007 Sorry Newbie here I didn't know I could [color:orange]name the webviewer. How do I do that so I can use it in the calc and copy the webviewer text to my field called "result" GetLayoutObjectAttribute ( "[color:orange]yourWVname" ; "content" )
Fenton Posted July 9, 2007 Posted July 9, 2007 If this is, as you say, for a Mac, then you can also run the built-in command-line tools from AppleScript, using the FileMaker Perform AppleScript script step. This is likely to be faster than loading a web page in the Web Viewer. It is a good way to get just a part of a web page, as you can use the built-in tools for searching text. That can get a little hairy for us not-totally-geeks -], but for simple stuff it is not bad. For example, the following will quickly find all the lines on this page which have the words "web viewer" in them. Run this in Script Editor to see the result. It could also be run in Perform AppleScript, and set into a FileMaker field. (The first line is all on one line.) set txt to quoted form of (do shell script "curl 'http://www.fmforums.com/forum/showtopic.php?tid/188290/post/257911/#257911'" without altering line endings) -- need to quote the text to escape spaces and other; need to retain the Unix line endings set theLines to do shell script "echo " & txt & " | grep -i 'web viewer'" -- -i is "ignore case", grep is case sensitive by default
hartmut Posted July 9, 2007 Author Posted July 9, 2007 I am going to need to put this in a windows situation. I have enclosed my file. I just want to get the text from the webviewer into the field "test" . If I can automate this I have solved my problem. I have enclosed a simple file to show this. Thanks Dave webviewertext.fp7.zip
Fenton Posted July 9, 2007 Posted July 9, 2007 Yeah, there's a problem here. Even though the text appears in the Web Viewer, you cannot get it (at least I can't). The usual method would be to first Name the web viewer object, using the Object Info pallet. (You didn't do this yet. But it doesn't fix it.) Then you'd use (I named it "WV") GetLayoutObjectAttribute ( "WV" ; "content" ) This will return the html source code of the web page; but it doesn't return that text. I tried another geocoder I know of; didn't work either. Basically I believe these geocoders are using Javascript to process your input and return text, and the web viewer, though it shows it, does not see it as html, and does not return it in a way that FileMaker can see it. I don't know the specifics, but that's what I see (or don't see in this case). Other geocoders can return text that FileMaker can see, either Google or Yahoo (they return xml). But both require you to register and get an application ID (which is free). However (and it's a big however), their licenses specifically forbid using this in a commercial application, unless you pay them big bucks ($10,000 per year for Google). Hence one has to think carefully whether to do use them in your situation. Or, as I originally said, you can use these other geocoders, but use command-line tools to get the results. This is pretty easy on Macs, not as easy on PC, but doable. Curl is also available for PC, but I've used another tool, which seems more user-friendly, which is "wget". Each PC would have to install it, and you'd have write the results to a file before reading it. Maybe there's a way to get that text out of Web Viewer. But I couldn't do it, other than manually selecting it and copying it (which works, but is not very automatic). What else is interesting is that these geocoders return slightly different results, very close, but not exactly the same.
Lee Smith Posted July 9, 2007 Posted July 9, 2007 Hi Fenton, I have been able to get to the text by using a couple of the Custom Functions that are posted on Brian's Site. I had good luck using the CFs posted by Mogens Brun, and his sample file posted here Link There are some others on Brian's site that help too. Lee
comment Posted July 9, 2007 Posted July 9, 2007 It's a Safari issue. You cannot view page source in Safari when the source page is plain text (I wonder if this is also true for IE in Windows). Instead of going around, why not just break in? webviewertext.fp7.zip
aholtzapfel Posted July 9, 2007 Posted July 9, 2007 I tried this and got nothing (Can't Copy and Paste from webviewer in script. Here is a simple Sample of Scraping using the url provided. WebViewText.zip
Fenton Posted July 9, 2007 Posted July 9, 2007 Comment's got it. It was the Select All step that was needed; the regular Copy [ Select contents ] was not doing it.
aholtzapfel Posted July 9, 2007 Posted July 9, 2007 I could not get comment's example to work at all. I cannot get it to Select the text let alone copy it. It may be that this technique will not work on Windows Vista (my test machine). When I first got 8.5 the Copy/Paste is the first thing I tried. (I wish It did work for me, It would be a whole lot easier than filtering the data you want from the Content) Anyone else have this problem?
DAVE/ Posted July 10, 2007 Posted July 10, 2007 Thats it. Thanks to all of you . I have been trying to do this for a while. Now I have something to work with and study. Very grateful Dave
comment Posted July 10, 2007 Posted July 10, 2007 It may be that this technique will not work on Windows Vista (my test machine). That is entirely possible. Just as your script will not work in Mac OS X (the very first step will fail). So maybe a branched script is required here.
Recommended Posts
This topic is 6407 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now