Shell script using curl to loop through urls

前端 未结 2 1723
囚心锁ツ
囚心锁ツ 2021-02-05 05:41

I\'ve been trying to create a simple script that will take a list of queries from a .txt file, append the main url variable, then scrape the content and output it to a text file

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-05 06:32

    Use more quotes !

    • http://mywiki.wooledge.org/Quotes
    • http://mywiki.wooledge.org/Arguments
    • http://wiki.bash-hackers.org/syntax/words

    Try this instead :

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

提交回复
热议问题