Jump to content

Downloading data from a website


This topic is 6643 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Take a look here:

http://jesse.cnsplug-ins.com/index.htm?category=AppleScript

But beware that a lot of switches could be needed to cope with sites out of the ordinary html.

http://curl.haxx.se/docs/httpscripting.html

--sd

Link to comment
Share on other sites

Thanks Soren. Now, do you know a way of taking text that is imported into a container, searching for keywords in the text, finding the text associated with those keywords and then copying and pasting in separate text fields? I hope this isn't too hard to do. It would make my life much easier.

Thanks

Link to comment
Share on other sites

Indeed provided the recieveing field is text, but an alternative could be piping further through a combination of sed and grep under shell scripting, would make the hit on storage less ...but also tougher to figure out.

--sd

Link to comment
Share on other sites

It seems though that Curl doesn't do everything. I've tried it on a few websites and comparing what Curl brings back to what is shown when you View Source in your internet browser. It seems Curl doesn't show all the html. Any other ideas on how to download a sites html into a text field in filemaker.

Link to comment
Share on other sites

My next step was to try to use Applescript in FileMaker to control safari to copy the source html of the front most page. Here is the code I used.

tell application "Safari"

activate

set frontmost to true

set theURL to URL of front document

set theTitle to name of front window

set theSource to source of front document

set the clipboard to theSource as Unicode text

end tell

The problem now is, Filemaker doesn't seem to see that there is text in the clipboard. I can paste it into TextEdit but not into FileMaker. Although the weird thing is, after pasting it into TextEdit I can select all and then copy that and FileMaker then sees text in the clipboard. I'm stumped.

Link to comment
Share on other sites

If you just want the text, you don't need to use the clipboard.

tell application "Safari"

set theName to name of document 1

set theURL to URL of document 1

set theText to text of document 1

end tell

You can then set theText (and others) into Filemaker fields (global for theText likely), then take it apart, ie.:

tell application "FileMaker Pro Advanced" -- line not needed in a Perform Applescript step

set cell "_gText" of current record to theText

end tell -- ditto

Link to comment
Share on other sites

Fenton your a genius. All I had to do is make one simple change to your script and it works perfectly. This is what I did.

tell application "Safari"

set theName to name of document 1

set theURL to URL of document 1

set theText to source of document 1

end tell

tell application "FileMaker Pro Advanced"

Perform Applescript step

set cell "Web content" of current record to theText

end tell

By changing the word text to source it now gives me the html code that I needed. This works better than what I was originally thinking. Thanks again.

Link to comment
Share on other sites

Now that I have the html in a text field I need to sort through it. What would be the best way of doing this?

For example:

In the following html I need to find the tag "Name:" first because that will always be there. Then I need to input the associated information "Jeremy Big" into a another text field.

Name: Jeremy Big

My questions are: What script would I need in FileMaker to find the Name: in the text field. Then how would I select "Jeremy Big" and copy and paste it into another text field named "Name". The reason I need to do a find first of Name: is that the associated data "Jeremy Big" will change.

Link to comment
Share on other sites

This topic is 6643 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.