Jump to content

Manipulating text (delete a big chunk of text)


Recommended Posts

I have no clue...the samples provided have no node with .id = StoreList1

edit: would you post a bit of the html? I'd prefer not to open unknown links :)

If the store names are directly under this node:

if $odiv.id = '"storeList1"' then consolewrite($odiv.outertext & @lf)

then modify to this:

If $odiv.id = '"storeList1"' Then
 For $oChild In $odiv.childnodes
  ConsoleWrite($oChild.innertext & @CRLF)
 Next
EndIf
; or output to array
If $odiv.id = '"storeList1"' Then
 $oStoreCol = $odiv.childnodes
 Local $aStores[$oStoreCol.length]
 $iCounter = 0
 For $oChild In $oStoreCol
  $aStores[$iCounter] = $oChild.innertext
  $iCounter+=1
 Next
 _ArrayDisplay($aStores)
EndIf
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

@jdelaney - Iterating the childnodes got everything except what I'm looking for.

More info:

When I view source from the "View" toolbar in IE I cannot see any of this HTML.

I can navigate to the node(s) I'm trying to get using "DebugBar" or "Developer Tools" (F12 in IE).

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

@jdelaney,

I have a file produced by

#include <array.au3>
#include <ie.au3>
#include <string.au3>

_IEErrorHandlerRegister("ERR")

local $odiv, $odivs, $url

$url =  'http://www.acehardware.com/mystore/storeLocator.jsp#53214|null'

return_addresses($url)

func return_addresses($url)

    local $str,$aADDR

    local $oIE = _IECreate($url,0,0)
    _IELoadWait($oIE)

    filewrite(@scriptdir & '\body.txt',_IEBodyReadHTML($oIE))

;~     local $odivs = _IETagNameGetCollection($oIE,'div')

;~     for $odiv in $odivs
;~         if $odiv.id = '"storeList1"' then
;~          For $oChild In $odiv.childnodes
;~              ConsoleWrite($oChild.innertext & @CRLF)
;~          Next
;~      endif
;~     next

    _IEQuit($oIE)
    $oIE = 0

endfunc

Func ERR()
    consolewrite(StringStripWS($oIEErrorHandler.WinDescription, 2) & @lf)
    ConsoleWrite('Id     = ' & $odiv.id & @LF)
    ConsoleWrite('Title  = ' & $odiv.title & @LF)
    ConsoleWrite('Class  = ' & $odiv.classname & @LF)
    ConsoleWrite(_stringrepeat('*',100) & @LF)
    Return
EndFunc

How can I upload it so you can look at it?

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

It's like whatever this site uses to generate its results is not easily found in the source. I've made two scripts already that do this same thing, except they were relatively easy to navigate. This one has been a thinker. There is a results div, with no code, no reference to any data..

Link to comment
Share on other sites

Your issue made me curious, but i went down a different path

You need an API key from google (which is free)

and JSMN from

#Include "JSMN.au3"
#Include <Array.au3>
#Include <File.au3>
Global $aFarray


$input = inputbox("Ace Hardware Finder" , "Enter Location" , "City State Address or Zip")
$location = stringreplace($input , " " , "+")

Local $Json = BinaryToString(InetRead("https://maps.googleapis.com/maps/api/place/textsearch/json?query=Ace+Hardware+"&$location&"&sensor=true&key=<YOUR KEY HERE>"), 4)
Local $Obj = Jsmn_Decode($Json)

$file = fileopen(@ScriptDir & "\JSON_RADIUS_OUTPUT.txt" , 2)
filewrite($file , Jsmn_Encode($Obj, $JSMN_PRETTY_PRINT))
fileclose($file)

_FileReadToArray(@ScriptDir & "\JSON_RADIUS_OUTPUT.txt" , $aFarray)

For $i = $aFarray[0] to 1 step -1
If stringinstr($aFarray[$i] , '"formatted_address": ') or stringinstr($aFarray[$i] , '"name": ') Then
ContinueLoop
Else
_ArrayDelete($aFarray , $i)
Endif
next

_ArrayDelete($aFarray , 0)

$results = Fileopen(@ScriptDir & "\results.txt" , 2)

for $j = 0 to ubound($aFArray) - 1 step 2
If stringinstr($aFarray[$j+1] , "Ace Hardware") or stringinstr($aFarray[$j+1] , "Ace Hdw") Then
filewrite($results , stringtrimright(stringtrimleft($aFArray[$j+1], 11),1))
filewrite($results , @CRLF)
filewrite($results , stringtrimright(stringtrimleft($aFArray[$j], 24),1))
filewrite($results , @CRLF)
filewrite($results , @CRLF)
Endif
Next

FileClose ($results)
shellexecute(@ScriptDir & "\results.txt")

using this solution for my zip code returns a text file that looks like:

"Keith's Ace Hardware"
"213 Mill Creek Drive, Salado, TX, United States"

"Ace Hdw at Cedar Park"
"200 South Bell Boulevard, Cedar Park, TX, United States"

"Ace Hardware"
"7708 Lohmans Ford Road, Lago Vista, TX, United States"

"Keith's Ace Hardware"
"201 S Frontage Rd, Lorena, TX, United States"

"Keith's Ace Hardware"
"408 West McGregor Drive, McGregor, TX, United States"

"Ace Hardware"
"1390 North Houston Street, Lorena, TX, United States"
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

https://developers.google.com/places/documentation/

the authentication section will walk you through it

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

see if the output.txt is empty too.

in your google developer console go to services, kick on all the maps and places. Then go to api access and make sure you are using the API key from "Simple API Access"

While you are just testing for output you could run with

#Include "JSMN.au3"

$input = inputbox("Ace Hardware Finder" , "Enter Location" , "City State Address or Zip")
$location = stringreplace($input , " " , "+")

Local $Json = BinaryToString(InetRead("https://maps.googleapis.com/maps/api/place/textsearch/json?query=Ace+Hardware+"&$location&"&sensor=true&key=<KEY>"), 4)
Local $Obj = Jsmn_Decode($Json)

consolewrite(Jsmn_Encode($Obj, $JSMN_PRETTY_PRINT))

until you get data

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

yeah i was editing the crap out of post #29 while you were posting that, sorry. Its just the key, It took a couple of minutes for mine to work, and couple of minutes of me putting in everything but the API key under Simple API Access. Should be a 40ish character AlphaNumeric string.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Sux, I have been further playing with radius queries via this method and it seems like a very reusable snippet for locationplace based searches. In your google API console, can you verify the services displayed in the far right pane of your overview (and that they are green 'No known issues'); and under API Access you only have "Simple API Access" and are using the API key from that section.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

You dont have the Places API listed.

edit: I posted an example that uses places details to capture phone number as well. It needs refinement of its own and did not want to derail this thread any further than i already managed to.

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...