Shell-Skript mit curl zum Durchlaufen von URLs

Ich habe versucht, erstellen ein einfaches Skript, das eine Liste von Abfragen aus .txt-Datei, fügen Sie die Haupt-url variable, dann kratzen Sie den Inhalt und die Ausgabe in eine Textdatei.

Hier ist, was ich habe, so weit:

#!/bin/bash

url="example.com/?q="
for i in $(cat query.txt); do
    content=$(curl -o $url $i)
    echo $url $i
    echo $content >> output.txt
done

Liste:

images
news
stuff
other

Fehler melden:

curl: (6) Could not resolve host: other; nodename nor servname provided, or not known
example.com/?q= other

Wenn ich diesen Befehl direkt von der Kommandozeile aus, bekomme ich eine Ausgabe in die Datei:

curl -L http://example.com/?q=other >> output.txt

Letztendlich würde ich gerne die Ausgabe:

fetched:    http://example.com/?q=other
content:    the output of the page

followed by the next query in the list.

InformationsquelleAutor der Frage Mena Ortega | 2013-04-21

Schreibe einen Kommentar