Results 1 to 5 of 5

Thread: Download pages/files from internet?

  1. #1
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    46
    Posts
    7,397
    Blog Entries
    2
    vBActivity - Stats
    Points
    327
    Level
    6
    vBActivity - Bars
    Lv. Percent
    61.54%
    Weekly Activity
    11.48%
    Rep Power
    10

    Download pages/files from internet?

    This thinBasic script will download default thinBasic web site page locally.
    The same can be used for whatever file from internet. Just change the url.

    [code=thinbasic] uses "INet"

    dim ret as number

    ret = INET_URLDownLoad("http://www.thinbasic.com", APP_SOURCEPATH + "Home.html")

    IF ret <> %TRUE THEN
    msgbox(0, "Error: " + ret)
    END IF
    [/code]
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  2. #2
    Junior Member
    Join Date
    Nov 2008
    Posts
    24
    vBActivity - Stats
    Points
    10
    Level
    1
    vBActivity - Bars
    Lv. Percent
    0%
    Weekly Activity
    1.91%
    Rep Power
    7

    Re: Download pages/files from internet?

    Quote Originally Posted by Eros Olmi
    This thinBasic script will download default thinBasic web site page locally.
    The same can be used for whatever file from internet. Just change the url.

    [code=thinbasic] uses "INet"

    dim ret as number

    ret = INET_URLDownLoad("http://www.thinbasic.com", APP_SOURCEPATH + "Home.html")

    IF ret <> %TRUE THEN
    msgbox(0, "Error: " + ret)
    END IF
    [/code]
    The code looks right to me, but for some reason, I can't get it to work on my computer. Using Windows XP home edtion.

    What might I be doing wrong. It doesn't produce any error messages, it just doesn't download the page.

    Thanks

    Bob

  3. #3
    Member matthew's Avatar
    Join Date
    Mar 2007
    Location
    England
    Age
    36
    Posts
    458
    vBActivity - Stats
    Points
    33
    Level
    2
    vBActivity - Bars
    Lv. Percent
    20.83%
    Weekly Activity
    1.91%
    Rep Power
    52

    Re: Download pages/files from internet?

    If you look in the folder where you saved the program you should find the downloaded html file.

    I'm running Vista & the program seems to work fine here.
    Operating System: Windows XP Home Edition 32bit SP3
    CPU: Intel Celeron M 360 @ 1.40GHz
    Memory: 1 GB RAM
    Graphics: SiS 661GX Mirage Graphics 32 MB

  4. #4
    Member
    Join Date
    Sep 2008
    Age
    37
    Posts
    326
    vBActivity - Stats
    Points
    10
    Level
    1
    vBActivity - Bars
    Lv. Percent
    0%
    Weekly Activity
    1.91%
    Rep Power
    37

    Re: Download pages/files from internet?

    The page will [download] AKASave to file)... EG, it will not [doanload & display] AKALaunch a viewer/browser.)
    INET_UrlDownload = Save to file. (If no path is set, it saves in script location. Dont forget the "http://" on the URL and the ".htm" on the file name.)
    INET_UrlDownload ("http://www.isawhim.com", "test.htm")
    Or...
    Load directly into a STRING
    INET_UrlGetString ("http://www.isawhim.com")

    To display/launch/run the file you downloaded, you would need to launch a viewer, or you can program your own viewer. If you want to open it with MSIE or FireFox or Opera or Netscape or Chrome... etc... you can use the commands in the "OS" module, called "OS_ShellExecute", which will (launch/open) the file.

    OS_ShellExecute("open", "test.htm", "", "", 1)
    or
    OS_ShellExecute("open", "test.htm", "", ".\", 1)

    Or, you can load the file into a string, with the "File" module using the "FILE_Load" command, that loads a file in one line. That is if you wish to edit the file data, or use the HTML-Data inside the file, to display your own way.

    [code=thinbasic]USES "Console"
    USES "File"
    USES "OS"
    USES "INET"

    DIM x AS STRING

    Console_PrintLine ""
    Console_PrintLine " --- Hit any key to begin ---"
    WAITKEY

    Console_Cls
    Console_PrintLine "Loading URL to STRING from URL"
    WAITKEY (3)
    x = INET_UrlGetString ("http://www.isawhim.com")
    Console_PrintLine x
    Console_PrintLine ""
    Console_PrintLine " --- Hit any key to continue ---"
    WAITKEY

    Console_Cls
    Console_PrintLine "Loading URL to FILE from URL"
    WAITKEY (1)
    Console_PrintLine " - One moment, fetching file..."
    INET_UrlDownload ("http://www.isawhim.com", "test.htm")
    Console_PrintLine "File downloaded, check script folder for ""test.htm"" file."
    Console_PrintLine ""
    Console_PrintLine " --- Hit any key to continue ---"
    WAITKEY

    Console_Cls
    Console_PrintLine "Loading FILE to STRING from FILE"
    WAITKEY (3)
    x = ""
    x = FILE_Load("test.htm")
    Console_PrintLine x
    Console_PrintLine ""
    Console_PrintLine " --- Hit any key to continue ---"
    WAITKEY

    Console_Cls
    Console_PrintLine "Launching FILE from THIS FOLDER"
    OS_ShellExecute("open", "test.htm", "", ".\", 1)
    Console_PrintLine " - File launched..."
    Console_PrintLine ""
    Console_PrintLine " --- Hit any key to exit ---"
    WAITKEY[/code]

    Remember, these commands, most of them, are from a programs perspective. From a user perspective, "Download" is "Get it, and show it", from a program perspective, "Download" is "Get it, and put it here".

    Hope that helps a little.

    If you want to make life a little easier, you can designate a special folder in C:\ for all your experimantal file read/write operations. Or, since the default location is "Where the script is run from." Develop all scripts in a special folder.

  5. #5
    Junior Member
    Join Date
    Nov 2008
    Posts
    24
    vBActivity - Stats
    Points
    10
    Level
    1
    vBActivity - Bars
    Lv. Percent
    0%
    Weekly Activity
    1.91%
    Rep Power
    7

    Re: Download pages/files from internet?

    Quote Originally Posted by matthew
    If you look in the folder where you saved the program you should find the downloaded html file.

    I'm running Vista & the program seems to work fine here.
    Thanks Matthew, I found it and it did work. Now to get it to come up and run when I ask it to...

    Thanks again.

    Bob

Similar Threads

  1. Do you need to download pages/files from internet?
    By ErosOlmi in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 2
    Last Post: 17-10-2006, 22:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •