Download a Tiddler Using Python/Bash

125 katselukertaa
Siirry ensimmäiseen lukemattomaan viestiin

j3d1H

lukematon,
17.5.2018 klo 15.36.0717.5.2018
vastaanottaja TiddlyWiki
Maybe a little off-topic, sorry. I want to use Python and/or Bash to copy a single tiddler from the TiddlyWiki file to a different file. Any clues on how to do this?

I would attempt to parse the file for the correct tiddler, but I would prefer not to do that, if there's a simpler way. It seems like it would be hard to do. I need to do this in a script, so I can't click "export tiddler".

Any help is appreciated!

Jed Carty

lukematon,
17.5.2018 klo 15.53.1817.5.2018
vastaanottaja TiddlyWiki
You may be able to do it using node, there is a script called ginsu in the repo that splits a wiki into tiddlers but I am not sure how to convert it to use python or bash.

Arlen Beiler

lukematon,
17.5.2018 klo 16.01.3717.5.2018
vastaanottaja TiddlyWiki
Well, the ginsu script would already be bash, or something similar. You need the node executable to run the script but you can call it from python or bash and then process the output. 

On Thu, May 17, 2018, 15:53 Jed Carty <inmy...@gmail.com> wrote:
You may be able to do it using node, there is a script called ginsu in the repo that splits a wiki into tiddlers but I am not sure how to convert it to use python or bash.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/216c309e-91e9-4e01-8fb9-ad0240cfe290%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

j3d1H

lukematon,
18.5.2018 klo 8.20.2918.5.2018
vastaanottaja TiddlyWiki
Jed: I would really rather not use node, it hasn't worked very well for me in the past. Any other possible solution?

Jed Carty

lukematon,
18.5.2018 klo 8.39.1218.5.2018
vastaanottaja TiddlyWiki
I haven't found any good server-side html parsing solutions. The node scripts are the only thing I have found that is at all reliable for pulling out tiddlers.

Matthew Lauber

lukematon,
18.5.2018 klo 11.28.0518.5.2018
vastaanottaja TiddlyWiki
I don't think there's really anything else someone's made.  You can try to do HTML munging using BeautifulSoup in python.  Should be able to use something like:

with open("NameOfFile.html") as f:
 soup
= BeautifulSoup(f.read(), "html.parser")


soup
.find_all('div', attrs={'title': 'NameOfTiddler'})

That'll get the the Div that represents the tiddler, but you'll have to figure out how to parse it.  And it relies on BeautifulSoup4, which you can get with 
pip install beautifulsoup4

Jeremy Ruston

lukematon,
18.5.2018 klo 11.35.2718.5.2018
vastaanottaja tiddl...@googlegroups.com
If you end up writing something from scratch, you might want to refer to the fairly simple code that TW5 uses to extract the tiddlers from TWC/TW5 HTML files:


Best wishes

Jeremy

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

j3d1H

lukematon,
24.5.2018 klo 10.43.3024.5.2018
vastaanottaja TiddlyWiki
Matthew Lauber: Sorry for getting back to you so late, but this works perfectly for what I need! Thank you.

Matthew Lauber

lukematon,
25.5.2018 klo 13.36.4225.5.2018
vastaanottaja TiddlyWiki
Glad to help.  If you do end up figuring out how to parse tiddlywiki wikitext in python/bash, please post about it to the group.  
Vastaa kaikille
Vastaa kirjoittajalle
Välitä
0 uutta viestiä