Asked — Edited
Resolved Resolved by WBS00001!

Reading Through An Rss File To Get Specific Data

I have been able to get and save the attached file to my hard drive. I can read it but I can not figure out how to pull just the data I want. In this case it is a stock quote for VZ. I want to just pull out the symbol and stock price.

I would appreciate any examples of how to accomplish that.

Thank You


ARC Pro

Upgrade to ARC Pro

Unleash your robot's full potential with the cutting-edge features and intuitive programming offered by Synthiam ARC Pro.

#57  

As Wall-E would say, "ta-da"

I have FINALLY uploaded a project with all the new stuff. Assuming you even care at this point. I wouldn't blame you if you didn't. It's been a MONTH after all. I'm very sorry for letting you down like that. It took so long because I didn't have as much time to work on it as I thought I would and I went wild with new paradigms, going through iteration after iteration until I boiled it all down into something sane. At least I think it's sane. The insane are always the last to know they're insane.

I've attached the new scrub program which has ancillary programs along with it for displaying errors to aid in troubleshooting. Also there is a much expanded ini file and an editing program to go along with it. The installer will place a new icon on your desktop from which to access the editor. It can also be accessed from within the "Main" script manager by pressing the Start button for the "ScrubIniEditor" script in the TextScrub script manager.

The attached file is a zip file containing an installation program to simplify the installation process. I've made the default installation path based on what you had earlier but you can changes it to whatever you wish. However, if you go ahead and use the default directory at least we will both have the same setup. That should make troubleshooting easier. Anyway, putting it into an entirely different directory will keep the new stuff from interfering with the old stuff.

I plan to add much more to the methodology I have started with this project but I am going to freeze this project as it is now. No matter what else I may do in the future I will be able to call this back up for making changes independantly of anything else. That way you won;t have to worry with changing your scripts again, once adapted to this way of doing things.

In addition is a project I have uploaded to the cloud which contains all the latest and greatest. It's called "Scraping Data From Web Pages." It has several Script Managers, but the one labeled "Main" is the one you will be interested in most. It contains the scripts dealing with the stock market webpages. The ones to the left contain scripts to support the ones in the Main Script Manager. In each Script Manager is a help script. CommonHelp, MainHelp, and TextScrubHelp. The one you will use to start off is MainHelp. Starting it will bring up a file with what you need to get started (that is, after you have installed the program files from the attached file).

The MainHelp file discuses things such as the Parameter Passing scheme and Stack usage, but mostly it goes over the changes brought about by the "Function Calling" methods used now and why this was done. It also goes over the layout of the example project.

I'm sure you will have questions galore, feel free to ask away. Or .. curse me and the very ground I walk on for changing it yet again. :) Seriously though, I believe in the end you will actually find it easier to use. It still does things in the same general way as before, just that the actual tasks are carried out by other scripts. This is done through a pseudo parameter passing scheme and CommandControl instructions instead of direct Goto commands within the same script, as is the case now. Overall, it should require minimal changes to your existing scripts.

TextScrubber.zip

PRO
USA
#58  

WBS00001 - The HTMLScrubber program no longer works with the latest version of exbuilder. I think the HTTPGET writes the file out differently. Any thoughts?

PRO
Synthiam
#59  

Send me an example and I'll see if anything had changed that would affect it

PRO
USA
#60  

Do you mean the code? Via email?

PRO
USA
#61  

nea.zip

Dj. There are 3 files. 1 is the script. the 2 other files must be placed in the directory public documents and folder test on the c drive.

This script runs with the older version of ARC but not the new. Something with either FileWrite or HTTPGet might be affecting it.

Run this on a pc with the older version and then try on a pc with the newer version.

Please let me know if you need more info.

PRO
USA
#62  

And any suggestions for script improvement would be appreciated. :D

PRO
Synthiam
#63  

I see what happened - i'll post an update today for you

PRO
Synthiam
#64  

Use the latest ARC and your code will work without needing to strip any characters. I modified your EZ-Script a little...


clearvariables()

$VZFile ="C:\temp\test.txt"

FileReadClose($VZFile)

$todaydate=($year + "-" + $month + "-" + $day)
$ready=0
$thenumber=1
$sortcounter=0
$arraycounter=0
$hazard=0

definearray($aname,20,"")
definearray($amag,20,"")
definearray($adiamin,20,"")
definearray($adiamax,20,"")
definearray($ahaz,20,"")
definearray($aclosedate,20,"")
definearray($aMPH,20,"")
definearray($amiles,20,"")
definearray($abad,20,"")

$url1 = "https://api.nasa.gov/neo/rest/v1/feed?start_date=" + $todaydate + "&end_date=" + $todaydate + "&api_key=3jMUBZIcgvFXVAMouSZqlWnbjg5N1sPmgsHiEyCD"

if (FileExists($VZFile))
  FileDelete($VZFile) #Clears the file and prevents adding to it needlessly
endif

FileWrite($VZFile,HTTPGet($url1))

$endOfFile = FileReadEnd($VZFile)

repeatuntil($endOfFile)

  $line = FileReadLine($VZFile)

  $field1 = Indexof($line,"name:")
  $field2 = Indexof($line,"absolute_magnitude_h: ")
  $field3 = IndexOf($line,"feet:")
  $field4 = indexof($line,"is_potentially_hazardous_asteroid: ")
  $field5 = indexof($line,"close_approach_date:")
  $field6 = Indexof($line,"miles_per_hour:")
  $field7 = indexof($line," miss_distance:")

  if ($field1 > -1)
    $field1a = Length($line)
    $name = (substring($line,$field1+5,$field1a-7))
  endif

  if ($field2 > -1)
    $field2a = Length($line)
    $mag = (substring($line,$field2+22,$field2a-24))
  endif

  if ($field3 > -1)
    $line = FileReadLine($VZFile)
    $field3a = IndexOf($line,"estimated_diameter_min: ")
    $diamin=(substring($line,$field3a+24,6))

    $line = FileReadLine($VZFile)
    $field3b = IndexOf($line,"estimated_diameter_max: ")
    $diamax=(substring($line,$field3b+24,6))

  endif

  if ($field4 > -1)
    $haz = substring($line,$field4+35,3)
  endif

  if ($field5 > -1)
    $field5a = indexof($line," ,")
    $closedate = substring($line,$field5+20,$field5a-21)

  endif

  if ($field6 > -1)

    $MPH = substring($line,$field6+15,7)

  endif

  if ($field7 > -1)
    $line = FileReadLine($VZFile)
    $line = FileReadLine($VZFile)
    $line = FileReadLine($VZFile)
    $line = FileReadLine($VZFile)
    $field7a = Length($line)
    $miles = (substring($line,7,$field7a-8))
    $ready = 1
    $field7 = -1

    # print($name)
    # print($mag)
    # print($diamin)
    # print($diamax)
    # print($haz)
    # print($Closedate)
    # print($MPH)
    # print($miles)
    # sleep(3000)
  endif

  if ($ready = 1 )

    $arraycounter=$arraycounter+1
    $aname[$arraycounter]=$name
    $amag[$arraycounter]=$mag
    $adiamin[$arraycounter]=$diamin
    $adiamax[$arraycounter]=$diamax
    $ahaz[$arraycounter]=$haz
    if ($ahaz[$arraycounter] = "fal")
      $hazard = $hazard
    ELSE
      $hazard = $hazard + 1
      $abad[$arraycounter]=$name
    endif
    $aclosedate[$arraycounter]=$closedate
    $aMPH[$arraycounter]=$MPH
    $amiles[$arraycounter]=$miles

    $ready=0

  endif

  $endOfFile = FileReadEnd($VZFile)

endrepeatuntil

filereadclose($VZFile)

repeatuntil($sortcounter = $arraycounter)

  if ($amiles[$thenumber]< $amiles[$sortcounter+1])
    $thenumber=$thenumber

  ELSE
    $thenumber=$sortcounter+1
  endif
  $sortcounter=$sortcounter+1
endrepeatuntil

if ($hazard = 0)
  $hazardstatement =(" None of these encounters are rated as potentially hazardous.")
ELSE
  $hazardstatement = ("with " + $hazard + " rated as potentially hazardou.")
endif

saywait(" There are " + $arraycounter + " Near Earth Asteroid Fly buys " + $hazardstatement)

if ($arrayCounter > 0)
  saywait(" The asteroid designated" + $aname[$thenumber] + " will safely pass by earth at a distance of " + round($amiles[$thenumber]) + " Miles.")
  saywait("It is estimated to be between " + round($adiamin[$thenumber]) + " feet and " + round($adiamax[$thenumber])+ " feet in diameter and, is traveling At a speed of " + (round($aMPH[$thenumber])) + " MPH.")
endif