r/ScriptSwap • • Feb 22 '19

Brainfart on script to convert html to txt/md HELP

# SOLVED I spoke too soon

So I made a little script to pull a webpage then convert to convert a webpage (blogs) into a txt/md file. You would only need to install lynx if you haven't already, I am having a small issue getting a variable to ... print?

I had print (URL) to verify the variable was saved correctly. But I cannot figure out how to call the variable in wget -O-...

additionally I would like to make <test> be the name of the article/blog/page. I presume parsed from URL, or truncated after the last / in (URL) .

#~ /bin/bash

URL = input("Enter a URL")

#print (URL)

f"wget -O- {URL} | lynx -dump -stdin > ~/Documents/name.txt"

Edit- I was halfway there, previous script had print "wget -O- (URL)... simply needed to change from parenthesis to curly brackets.

if you want to download to a "true" markdown format install pandoc and follow the directions in the pandoc section here. But I think this script is only printing the function, not "running" the function. If you type out the last string (minus f and insert a proper URL) you will get a txt file of the blog.

3 Upvotes

7 comments sorted by

View all comments

1

u/JIVEprinting Feb 22 '19

Are you thinking of html2txt ?

1

u/THEdirtyDotterFUCKr Feb 22 '19

No. Html2txt jumbles txt more often than not.

Lynx does a great job of cleaning up. pandoc is great for making markdown files

1

u/JIVEprinting Feb 22 '19

I'll be forever grateful to pdf2txt for allowing a hack on locked PDF bank statements.