Page 4 of 4 FirstFirst ... 234
Results 46 to 55 of 55

Thread: Save an HTML table as CSV

  1. #46
    Join Date
    Mar 2014
    Corpus Christi, TX
    I have been tinkering with VBS on this issue. I have a script that kinda-sorta works, and what doesn't seem to work is very puzzling. When I get back to the office I will post the script for your review... if you're so inclined. Thank you for being so patient and helpful with this.

  2. #47
    Join Date
    Mar 2009
    If all else fails, you can always do the trick of dynamically adding a script tag to the page which in reality sends data to an active program, as in

    var head = document.getElementsByTagName('head');
    var notAJAX = document.createElement('script');
    notAJAX.src = "http://whereEver.com/destination.php&myData=stuffToBeSent";
    It does have all the limitations of any GET call, but you don't have any "common origin" problems.

  3. #48
    Join Date
    Mar 2014
    Corpus Christi, TX
    Tcobb - Where in the script does this belong, and what else would I need to edit? It appears I would simply put this at the beginning of the HTML file to run on the local machine and simply edit the notAJAX.src URL. Am I missing anything else here?

  4. #49
    Join Date
    Mar 2014
    Corpus Christi, TX
    Here is the portion of the VBS that is not working. For some reason, CTRL+A doesn't execute. Any thoughts as to what might be going wrong?

    wscript.sleep (10000)Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.SendKeys "admin"
    WshShell.SendKeys "{TAB}"
    WshShell.SendKeys "xPr3$$"
    WshShell.SendKeys "{ENTER}"
    wscript.sleep (4000)
    WshShell.SendKeys "^{a}"
    WshShell.SendKeys "^{c}"
    WshShell.SendKeys "^{w}"

  5. #50
    Join Date
    Mar 2009
    This may be, and probably is, of no value to you whatsoever. I have never really been completely clear on the topology of your setup. I take it that:

    1. The information that you want to grab and transmit is funneled through the server on the local network, which does not itself have access to the internet.

    2. Your laptop computer has access both to the local network and the internet as well.

    3. You have some control over the local server. You could add some javascript to the page which contains the table.

    --If you have answered no to any of these questions, ignore the rest of this post.

    As far as using dynamically generated script tags to send cross-domain information, here is an example.

    var scr;
    function zap(input){
       var head = document.getElementsByTagName('head');
       head = head[0];
       scr = document.createElement('script');
       scr.defer = true;
       scr.src = "" + '?data=' + input;
    window.onload = function(){  //extract data from page and send to server
       var z = document.getElementById('d1');
    <div id="d1"> FRED </div>
    Notice it is calling for something other than a static js file. And although the example references a php script on the local computer it can really access it at any domain where the script resides.


    $str = 'alert("Hello ' . $_GET["data"] . '");';
    The main thing is that the server's response must be some valid javascript. The example here extracts data from the page, sends that to the server, which processes it like any form data, and then sends some javascript back. And there are problems with doing this. Its an imperfect substitute for AJAX, and you do need the server to cooperate to send anything back.

  6. #51
    Join Date
    Mar 2014
    Corpus Christi, TX
    I have fixed the VBS by adding sleep commands after each CTRL+X SendKeys. I now have a CSV of the data from the stalist.cgi page.

  7. #52
    Join Date
    Mar 2005
    Behind you...
    Well it looks like VBS is turning out to be a real hero for your problems.

    Are you able to import the CSV yourself or do you need some scripting for that?
    "Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"

  8. #53
    Join Date
    Mar 2014
    Corpus Christi, TX
    I really appreciate all your help. I'm taking a stab at importing the CSV's and I've already made some progress. The problem I'm going to have is having the script cycle through all the CSV's in a folder for import, then deleting all files after upload.

  9. #54
    Join Date
    Mar 2014
    Corpus Christi, TX
    Now comes the fun part... putting everything where it belongs.

    I have attached the script I am using to import the information from the CSV into the MySQL database. My goals:

    • Get the file name for entry into the database (I can pass this in the URL if needed)
    • Remove the erroneous three rows at the top of each CSV file (two blank rows and one header row)
    • Have the script cycle through and execute for all CSV's in the directory
    • Delete the CSV's after being imported

    My thought is that the individual laptops will run the script to get the data from stalist.cgi and upload the CSV every hour. Then, half-past every hour, this script will run that imports all CSV files into the database. This gives the computers time to process and upload and ensure I have the most accurate data possible.

    Here is the script I have started with. As you can tell, I am specifying one particular CSV file to be read. I haven't figured out a way to have the script execute for all files. TIMTACULAR is the name of my computer, so you can see that the computer name is used the filename. It makes no difference to be whether the file name, or computer name (via URL) is used.

    $link_id = mysql_connect("localhost", "**", "***") or die("Could not connect."); if(!mysql_select_db("speedtest",$link_id)) die("database was not selected.");
    $file_handle = fopen("resultupload/TIMTACULAR.csv", "r");
    while (($line_of_data = fgetcsv($file_handle, 1000, ",")) !== FALSE) { $line_import_query="INSERT into bridges(MAC,DeviceName,SignalNoiseDBM,Distance,TxRxMbps,CCQ,ConnectionTime,LastIP) values('$line_of_data[0]','$line_of_data[1]','$line_of_data[2]','$line_of_data[3]','$line_of_data[4]','$line_of_data[5]','$line_of_data[6]','$line_of_data[7]')"; mysql_query($line_import_query) or die(mysql_error()); 
    http://timweitzel.net/wasp/TIMTACULAR.csv - Link to the actual CSV file being saved.
    http://timweitzel.net/wasp/rxbridge.PNG - List of Columns in the database

  10. #55
    Join Date
    Mar 2014
    Corpus Christi, TX
    I can see where this portion needs to be in a PHP forum. I will copy it there as to not confuse people. Hopefully this will help other developers along the way.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.11727 seconds
  • Memory Usage 2,950KB
  • Queries Executed 15 (?)
More Information
Template Usage (36):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (10)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (74):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates