download an html file via wget and pass it to mysql and update a database

CAN I download an html file via wget and pass it to mysql and update a database field?

YES, you CAN!

You're the second person to say that.

It might be the RIGHT answer, technically speaking.

But it is not helpful!

OP: Please phrase your question better. Such as "How can I ...".

Yes i was the first to have the same reply.

I know it's not helpful but i think, it's the best answer we can have to such a generic and unclear question.

You are right, scottn, but please don't mind, that was just a joke.
I hope I could always be helpful.

html=`wget -q -O - http://url.com`
# html=`curl -s http://url.com` # would be more succinct
mysql -uuser -ppwd -h HOST -P PORT -D DB_NAME -A -e "UPDATE TABLE SET COLUMN=\'$html\' WHERE x=y"

Note: you may have to escape some special characters in $html for MySQL, otherwise, the UPDATE statement may fail.

---------- Post updated at 11:31 AM ---------- Previous update was at 11:28 AM ----------

:smiley:

I use it in this way but I have this error:
syntaxa error at line 26

mysql -v -v -v -uXXX -pYYYYY -e 'UPDATE products \
INNER JOIN tb_GGGGG ON products.products_model = tb_GGGGG.ItemID \
INNER JOIN products_description ON products.products_id = products_description.products_id
SET \
products_description.products_description = \'$html\'  WHERE  (products.products_model = "Y")' MYDB

if instead of $ html put '1234567890 'then the query works

It is most likely that your HTML file has special characters you should escape for mysql, like single-quotes, try escaping them by replacing each single-quote with triple-quotes.

I did some tests and these two loads them:

html="</head><body>A<br>A<br>A<br></body>"

or

html='<html><head><meta content="text/html; charset=ISO-8859-1"http-equiv="content-type"><title></title></head><body>A<br>A<br>A<br></body></html>'

but not this:
html=$(wget -q -O - url.com)

in query:

products_description.products_description =${html}\' WHERE (products.products_model = "Y")' MYDB

the quotes I have to replace them in the html code?