idea : extract specific information out of html file / code store it into
respective field in database.
ex. fruit search engine web-page
1 you introduce what you seeking ex. apple
2 executing search
3 getting result page (with for ex fields like:
color,size, price, etc…)
the results you see it in the result page in the browser, now to extract the results I assume you have to use html source code
4 defining position of every field ( by the text
that is in front and behind the field. ex
color,that means the expession in the source
code that is in front of the color and behind)
5 the so identified color store it in color field
of your database and proceed with the next
field.
SHORT : EXTRACT X-FIELDS OUT OF A WEB-PAGE TO BE
STORED IN CORRESPONDENT FIELD OF DATABASE
THX for having a look I hope it’s more or less clear
You need three tools and a little of effort: AppleScript installed ( :lol: ), URL Access Scripting & Filemaker.
Also, you can substitute URL Access Scripting for a web browser, but theorically you don’t need it. Step 1. “Download” the web page with results from a search query. Look at URL Access Scripting dictionary. You should see a command called “download” with several parameters. You can download an URL such as “http://www.google.com/search?hl=en&ie=ISO-8859-1&q=apple”, which will give you a HTML page with the results of searching “apple” at Google. Step 2. “Read” this web page. You can find some useful commands within “Standard Additions”’ terminology: open for access, read, close access. Step 3. Extract the info you’re looking for from this text and enclose it into variables, for later use. Step 4. Put this info within your FM db (this is easy; look at FM’s dictionary).
If you need some detailed info about any particular question, this is your site!
AppleScript defines several properties & command to work with strings. You can extract from a given text its “word 1” or its “character 6”, or a bunch of text “characters 1 thru 8”.
Also, you can determine the position of a given string into a long text offset of “text” in “Hello, text!” (which will return “8”… character 8 is “t”).
So, if we call “html_code” to the text you’ve posted:
set x to (offset of "Maturity date(*)</strong></td>
<td class='secdb'>" in html_code) + 50
set y to (offset of " </td>
</tr>
<tr height="3">" in html_code) - 1
set maturity_date to text from character x of html_code to character y of html_code
--> "16 May 2010"
I sum 50 to x because I don’t want include that string into my calculation. 50 is the length of “Maturity date(*)</str…”.
And I rest 1 to y because I don’t want include “&” into the string…
Now, set the value of a FM’s field may be easy:
tell application "FileMaker Pro"
set cell "maturity" of record 54 of database 1 to maturity_date
end tell
I think I follow your idea, I try the script
and I’m sure I made small mistake it says
the variable html_code is not defined.
How can I tell the script to find the string in a
specific html file in a specific folder ??
Where is located “test.html”? If it is at root level, your alias will be:
alias "mac - osx:test.html".
If not, you can select the file in the Finder and run this code:
tell application "Finder"
selection as alias
end tell
And it will return the path to the file.
Also, if you work with any script editor different than Apple’s “Script Editor” (Smile, freeware, http://www.satimage.fr/software/en/softx.html; or Script Debugger, shareware, http://www.latenightsw.com/) you can drag & drop any file into a script window and the path will be automatically placed at the window…