如何将wget输出传输到文件或数据库? [英] How do I transfer wget output to a file or DB?

查看:658
本文介绍了如何将wget输出传输到文件或数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用小型脚本从多个网页下载字段。一方面,我只能从一个页面...,但我真正的问题是,我不知道如何把输出关闭到一个数据库表?如何从curl / lynx | grep(这将是所有列表项)的输出,并将其列表项列表项移动到我的数据库中的表或CSV,其中它将准备好导入到数据库?

I'm trying to use a small script to download a field from multiple pages. For one thing, I'm only able to get it from one page..., but the real problem I'm having is that I don't know how to hand the output off to a database table? How can I take the output from curl/lynx|grep (which is going to be all the list items) and move it, list item by list item, to a table in my DB or to a CSV where it will be ready for import to the DB?

#!/bin/bash

lynx --source "http://www.thewebsite.com"|cut -d\" -f8|grep "<li>"

我将连接到的数据库将是一个MySQL数据库,我们可以调用虚拟表listTable。请尝试坚持使用bash?我不允许在我使用的服务器上编译,看起来不能得到curl使用PHP。无论如何,我想我需要一个变量,然后系统地传递变量的内容到数据库,对吗?

The database I would connect to would be a MySQL database. We could call the dummy table "listTable". Please, try to stick to bash? I'm not allowed to compile on the server I'm using, and I can't seem to get curl to work with PHP. Anyway, I'm thinking I need to make a variable and then systematically pass the contents of the variable to the database, right?

推荐答案

使用类似awk,sed或perl的东西来创建INSERT语句,然后管道到你的sql客户端(psql或mysql)。

Use something like awk, sed or perl to create INSERT statements, then pipe that to your sql client (psql or mysql).

这篇关于如何将wget输出传输到文件或数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆