PROCE MAIN(cUrl)
LOCAL cMemo:="",nAt,cText,aH:={},aData:={},cText1,aNew:={},I
DEFAULT cUrl :="adaptapro"
cUrl :=ALLTRIM(cUrl)
cUrl :="https://www.instagram.com/"+ALLTRIM(cUrl)+"/"
cMemo:=WebPageContents( cUrl, .t. )
IF "not-logged-in"$cMemo
MsgInfo("Usuario no Logeado","Debes Ingresar a Instagram con Usuario y Clave")
RETURN {}
ENDIF
WHILE .T.
nAt :=AT("\n#",cMemo)
IF nAt=0
EXIT
ENDIF
cText :=SUBS(cMemo,nAt+2,LEN(cMemo))
cText1:=cText
nAt :=AT("}}]",cText)
cText :=LEFT(cText,nAt-2)
cText :=STRTRAN(cText,"\u00f3","ó")
cText :=STRTRAN(cText,"\u00e1","á")
cText :=STRTRAN(cText,"\u00e9","é")
cText :=STRTRAN(cText,"\u00ed","í")
cText :=STRTRAN(cText,"\u00e1","á")
cText :=STRTRAN(cText,"\u00fa","ú")
aH :=_VECTOR(cText," ")
ADEPURA(aH,{|a,n| Empty(a) .OR. LEFT(a,1)<>"#"})
AEVAL(aH,{|a,n|AADD(aData,a)})
nAt :=AT("\n#",cText1)
cText :=SUBS(cText1,nAt+0,LEN(cText1))
nAt :=AT("}}]",cText)
cMemo :=SUBS(cText,nAt+2,LEN(cMemo))
cText :=ALLTRIM(LEFT(cText,nAt-2))
cText :=STRTRAN(cText,"\n"," ")
cText :=STRTRAN(cText,"\u00f3","ó")
cText :=STRTRAN(cText,"\u00e1","á")
cText :=STRTRAN(cText,"\u00e9","é")
cText :=STRTRAN(cText,"\u00ed","í")
cText :=STRTRAN(cText,"\u00e1","á")
cText :=STRTRAN(cText,"\u00fa","ú")
aH :=_VECTOR(cText," ")
ADEPURA(aH,{|a,n| Empty(a).OR. LEFT(a,1)<>"#"})
AEVAL(aH,{|a,n|AADD(aData,a)})
ENDDO
aNew:={}
FOR I=1 TO LEN(aData)
nAt:=AT(["],aData[I])
IF nAt>0
aData[I]:=LEFT(aData[I],nAt-1)
ENDIF
IF "#\"=LEFT(aData[I],2)
aData[I]:=""
ENDIF
IF "#o\"=LEFT(aData[I],3)
aData[I]:=""
ENDIF
IF "\u00a0"$aData[I]
aData[I]:=STRTRAN(aData[I],"\u00a0","\n")
ENDIF
IF "\n"$aData[I]
aData[I]:=STRTRAN(aData[I],"\n"," ")
aNew:=_VECTOR(aData[I]," ")
aData[I]:=aNew[1]
AEVAL(aNew,{|a,n| AADD(aData,a)})
ENDIF
NEXT I
ADEPURA(aData,{|a,n| Empty(a)})
aNew:={}
FOR I=1 TO LEN(aData)
nAt:=ASCAN(aNew,{|a,n|a==aData[I]})
IF nAt=0
AADD(aNew,aData[I])
ENDIF
NEXT I
? "visualizar el array",aNew
//ViewArray(aNew)
RETURN aNew
FUNCTION _VECTOR(cPar,cSepara)
LOCAL nPos,aLista:={},X,nLen,SEP1,SEP2
IF ValType(cPar)="A"
RETURN cPar
ENDIF
cSepara=IF(cSepara=NIL,",",cSepara) // CON LOS SEcParADORES
SEP1="]"+cSepara+"["
SEP2=cSepara+" "
DO WHILE .T.
nLen=3
nPos=AT(SEP1,cPar) // AT("],[",cPar)
IF nPos=0
nPos=AT(cSepara,cPar) // AT(",",cPar)
nLen=1
ENDIF
IF nPos=0
nPos=AT(SEP2,cPar) // AT(", ",cPar)
nLen=2
ENDIF
IF nPos=0
EXIT
ENDIF
X=LEFT(cPar,nPos-1)
AADD(aLista,X)
cPar=SUBS(cPar,nPos+nLen,LEN(cPar))
ENDDO
IF LEN(cPar)>0 //.OR.RIGHT(XcPar,1)=cSepara // despues del SecParador esta vacio
AADD(aLista,cPar)
ENDIF
RETURN aLista
// Depura Valores vacios
// Jn 30/08/2014
FUNCTION ADEPURA(aArray,bBlq)
LOCAL nAt,aNew:={}
IF LEN(aArray)>0 .AND. ValType(aArray[1])="A" .AND. LEN(aArray[1])>1
DEFAULT bBlq:={|a,n| Empty(a[1])}
ELSE
DEFAULT bBlq:={|a,n| Empty(a)}
ENDIF
WHILE .T.
nAt:=ASCAN(aArray,bBlq)
IF nAt=0
EXIT
ENDIF
ARREDUCE(aArray,nAt)
ENDDO
RETURN aArray
/*
// Reduce el Arreglo
*/
FUNCTION ARREDUCE(aArray,nAt)
IF ValType(aArray[nAt])="A" // Borrar Objetos
Aeval(aArray[nAt],{|a,n|aArray[nAt,n]:=NIL})
ENDIF
IF ValType(aArray[nAt])="O" // Borrar Objetos
aArray[nAt]:=NIL // Borrar Objetos
ENDIF
ADEL(aArray,nAt)
ASIZE(aArray,Len(aArray)-1)
RETURN aArray