|
Post by alexfish on May 29, 2017 12:38:44 GMT 1
Hi All after a dedermined effort to get Raspberry PI "hugrpi" widgets to have a browser widget the end result as in a route to get the info as in a cli search engine + route to get graphics links from a text based browser , yes they are cli , googlecl which is in the repos , but fails then I stumble upon googler so in short if u want can install googler. `googler` requires Python 3.3 or later. Only the latest patch release of each minor version is supported. sudo curl -o /usr/local/bin/googler https://raw.githubusercontent.com/jarun/googler/v3.1/googler && sudo chmod +x /usr/local/bin/googler
then install lynx from the repos via synaptic or from the apt-get install command sudo apt-get install lynx lynx has a dump command and as far as can tell the only text base browser that has an include graphis link with dump can use man * to see what for bacon usage both work well example code Updated -- the odd bits == terminal color codes , hence the key switch --nocolor ... ' get the results of googler
A$ = EXEC$("googler --nocolor --np bacon linux | grep http") LOCAL x , t LOCAL getdata$, trimit$ SPLIT A$ BY NL$ TO N$ SIZE x C$ = "lynx -image_links -dump " FOR t = 0 TO x-1
IF INSTR(N$[t],"http://www.basic-converter.org/") THEN C$ = C$ & CHOP$(N$[t]) A$= EXEC$(C$) PRINT " Look Up Result : ->", A$
BREAK ENDIF NEXT
then u will see where it be heading. should work on other system other than raspy / debian Note the links at the bottom of the print out with a little bit of parsing <imagination> ,it should also be possible to make a home brewed text + graphics with hug as well FINAL:: Hug version with Image Viewer in source code Archive Updated Archive :: Listlinks now inlude link number to match Browser view link number + Bug Fixes Updated Archive :: load button changes :: either Load to load + load links :: View only View only Retains Existing LIST> Links Updated Archive :: Bug Fixes and optimizing BR Alex Attachments:browser.bac.bz2 (2.19 KB)
|
|
|
Post by alexfish on May 29, 2017 16:19:56 GMT 1
Hi All
Found a problem with the split
EG
' get the results of googler
A$ = EXEC$("googler --np bacon linux | grep http") LOCAL x , t
SPLIT A$ BY NL$ TO N$ SIZE x
FOR t = 0 TO x-1 'PRINT N$[t] IF INSTR(N$[t],"http://www.basic-converter.org/") THEN PRINT "-------------------" , x C$ = "lynx -image_links -dump " & CHOP$(N$[t]) PRINT "Look Up : -> " ,C$ A$= EXEC$(C$) PRINT "Look Up Result : ->", A$
C$= "lynx -image_links -dump " & "http://www.basic-converter.org/" A$= EXEC$(C$) PRINT "Concat Strings Look Up Result : ->", A$
BREAK ENDIF NEXT
example output of the get site with the concat
C$ = "lynx -image_links -dump " & CHOP$(N$[t])
result
Look Up : -> lynx -image_links -dump http://www.basic-converter.org/ Look Up Result : -> Alert!: Unsupported URL scheme!
lynx: Start file could not be found or is not text/html or text/plain Exiting...
Then the
C$= "lynx -image_links -dump " & "http://www.basic-converter.org/"
the beginning of the output
Concat Strings Look Up Result : -> (BUTTON) [1]BaCon * [2]About * [3]News * [4]Downloads * [5]Documentation * [6]Examples * [7]Extensions * [8]Links * [9]FAQ * [10]Forum
BaCon - BASIC to C converter
Easy to learn
BaCon syntax is based on old-school BASIC. [11][arrow1.png] [12][app-bg.png] [13][arrow2.png]
Fast and powerfull
Any ideas
BR Alex
|
|
|
Post by alexfish on May 29, 2017 18:33:39 GMT 1
found the problem
looks like extra chars are been added during the get exec
found these at the end of each htpp *
[0m
so it is not a bacon problem
hopeful of a fix using ctypes edit
also found these chars at the beginning
[93m BR Alex
|
|
|
Post by alexfish on May 29, 2017 20:57:44 GMT 1
Hi All looks like the extra bytes are constant
this code works on the Raspberry PI
' get the results of googler
A$ = EXEC$("googler --np bacon linux | grep http") LOCAL x , t LOCAL getdata$, trimit$ SPLIT A$ BY NL$ TO N$ SIZE x C$ = "lynx -image_links -dump " FOR t = 0 TO x-1
IF INSTR(N$[t],"http://www.basic-converter.org/") THEN
trimit$= N$[t] trimit$ = MID$(trimit$,6) trimit$ = LEFT$(trimit$,LEN(trimit$)-4) C$ = C$ & trimit$ A$= EXEC$(C$) PRINT " Look Up Result : ->", A$
BREAK ENDIF NEXT
BR Alex
|
|
|
Post by vovchik on May 29, 2017 21:12:06 GMT 1
Dear Alex, Thanks. Nice, terse and useful. I did something like that in bash/yad, using googler a while back. Your code is very minimal and gets the job done. With kind regards, vovchik
|
|
|
Post by alexfish on Jun 3, 2017 17:26:09 GMT 1
Hi All
found that the odd bits = terminal color codes
key switch no has '-- nocolor '
Updated code now at first post
BR Alex
|
|
|
Post by alexfish on Jun 3, 2017 20:58:04 GMT 1
Hi All
a HUG version of text Browser .. Requires 'googler' & 'lynx' .. see first post
hopefull , your system has /Downloads directory . if not adapt the path
@
DLDir$ = USR$ & "/Downloads/"
usage
type in the search box , keyboard RETURN will search or Click Search
a list of URL's will appear
Click on a URL , it should appear in the top url entry , click LoadPage
For Down loads , copy the URL to Entry Download , Click DownLoad Button
DownLoad message will be seen in the bottom editor
---------------------------------
this will form the base of a minimal text browser using hug.bac .. hopeful to employ graphics at some stage
BR Alex
The Code ,
INCLUDE hug.bac
DECLARE CurDir$ DECLARE USR$ DECLARE CURURL$ ' ------------------------------------------------------------------------------ SUB Search() ' ------------------------------------------------------------------------------ LOCAL C$ LOCAL A$ LOCAL gog$ LOCAL getln$ LOCAL x , t
getln$ = CHOP$(GRAB$(sch)) gog$ = "googler --nocolor --np " & getln$ & " | grep http"
A$ = EXEC$(gog$)
SPLIT A$ BY NL$ TO N$ SIZE x
TEXT(lst,"") IF INSTR(A$,"[ERROR]" ) THEN TEXT(lst,N$[0]) ELSE
FOR t = 0 TO x-1 IF LEN(N$[t]) !=0 THEN TEXT(lst,N$[t]) END IF NEXT ENDIF
END SUB
' ------------------------------------------------------------------------------ SUB geturl() ' ------------------------------------------------------------------------------ TEXT(url,GRAB$(lst)) SHOW(lst) HIDE(ed) ENDSUB
' ------------------------------------------------------------------------------ SUB LoadPage() ' ------------------------------------------------------------------------------ LOCAL A$ LOCAL B$ LOCAL C$
A$ = "lynx -image_links -dump " B$ = GRAB$(url)
IF INSTR(A$,"http") >=0 THEN A$= A$ & B$ C$= EXEC$(A$) TEXT(ed,"") CURURL$=B$ TEXT(ed,C$) HIDE(lst) SHOW(ed)
ELSE CURURL$ = "" END IF
END SUB ' ------------------------------------------------------------------------------ SUB DownLoad() ' ------------------------------------------------------------------------------ LOCAL DLDir$ LOCAL A$ LOCAL B$ LOCAL C$
B$ = CHOP$(GRAB$(dls)) TEXT(sec,"") IF INSTR(B$,"http") >=0 THEN A$ = "wget " & B$ DLDir$ = USR$ & "/Downloads/" CHANGEDIR DLDir$ C$ = EXEC$(A$) TEXT(sec, C$) CHANGEDIR CurDir$
ELSE A$ = "wget " & CHOP$(CURURL$) & CHOP$(B$) PRINT A$ DLDir$ = USR$ & "/Downloads/" CHANGEDIR DLDir$ C$ = EXEC$(A$) TEXT(sec, C$) CHANGEDIR CurDir$ END IF
ENDSUB ' ------------------------------------------------------------------------------ CurDir$ = CURDIR$ USR$ = GETENVIRON$("HOME") PRINT CurDir$ PRINT USR$ win = WINDOW("Mini Text Browser",700,600)
url = ENTRY("",600,30) sch = ENTRY("",600,30) ed = EDIT(700,400) but = BUTTON("LoadPage",100,30) lst = LIST(700,400) dls = ENTRY("",600,30) dlB = BUTTON("DownLoad",100,30) srch = BUTTON("Search",100,30) sec = EDIT(700,95)
ATTACH(win,url,0,0) ATTACH(win,sch,0,31) ATTACH(win,lst,0,62) ATTACH(win,ed,0,62) ATTACH(win,but,600,0) ATTACH(win,dls,0,470) ATTACH(win,dlB,600,470) ATTACH(win,sec,0,505) ATTACH(win,srch,600,31) CALLBACK(lst,geturl) CALLBACK(sch,Search) CALLBACK(but,LoadPage) CALLBACK(dlB,DownLoad) CALLBACK(srch,Search) HIDE(ed)
DISPLAY
|
|
|
Post by vovchik on Jun 3, 2017 21:48:22 GMT 1
Dear Alex,
It is tiny and is an excellent way of getting to real files if they are not hidden by javascript. Thanks.
Wit kind regards, vovchik
|
|
|
Post by alexfish on Jun 4, 2017 17:07:47 GMT 1
Hi All A Beta HUG Version of Text Browser with Image View is at First Post Enter search words in Search ENTRY adj ti the Search button a list will appear , click on a URL , click Load page Click ViewLinks & View Page BUTTONS To Download a file or image Toggle the ViewLinks BUTTON Click on the links The Links are directed to either the URL entry or The DownLoad Url A check is made , if the file exists the there will be no down load + if file = image .png or .jpg the the image is displayed BR Alex And A Picky Attachments:
|
|
|
Post by alexfish on Jun 4, 2017 20:58:46 GMT 1
Hi All
HUG text browser with Image View :: Final Update At Post #1
BR Alex
|
|