使用不同参数执行多个cURL请求 - 在意外令牌附近抛出-bash:语法错误`('

时间:2016-06-23 18:39:52

标签: bash curl

我正在做这样的多个cURL请求:

curl 'http://www.website.com/app/application' -H 'Cookie: _cb_ls=1; em_cdn_uid=t%3D1463525134354%26u%3D86461fb6689e46c4a62881ce3357cbcc; em_p_uid=l:1463668963788|t:1463525135884|u:f3d8947c76024450885843f258571c45; __auc=b15c4507154c0e31047b3844aa7; _cb=CVUoIeDh7JhxCGgn1b; _chartbeat2=.1463525007080.1465845135479.0000000011110001; _ga=GA1.2.1272946403.1463524985; _gat=1; __utma=158138023.1272946403.1463524985.1466007370.1466019639.16; __utmb=158138023.0.10.1466019639; __utmc=158138023; __utmz=158138023.1465409755.13.3.utmcsr=facebook.com|utmccn=(referral)|utmcmd=referral|utmcct=/; __utmv=158138023.|1=custID=83f090439770a6e6cc0cb324504524e7=1' -H 'Origin: http://www.latercera.com' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: es-ES,es;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36' -H 'Content-type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: text/javascript, text/html, application/xml, text/xml, */*' -H 'X-Prototype-Version: 1.6.1' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Referer: http://www.website.com/resultadoBusqueda.html?q=KEYWORD' --data 'action=searchSolr&type=CONTENT&siteCode=TEFURVJDRVJB&fq=taxonomyId%3A24%20AND%20status%3A2%20AND%20launchDate%3A%5B2008-05-31T23%3A59%3A59.999Z%20TO%20NOW%5D&indent=on&wt=json&qt=default&sort=launchDate%20desc&start=0&rows=15&q=KEYWORD&_=' --compressed > MyFile.txt

我在网站上查找了多个关键字(超过1.500),因此我使用concat函数更改了Excel中的cURL指令,结果如下:

curl 'http://www.website.com/app/application' -H 'Cookie: _cb_ls=1; em_cdn_uid=t%3D1463525134354%26u%3D86461fb6689e46c4a62881ce3357cbcc; em_p_uid=l:1463668963788|t:1463525135884|u:f3d8947c76024450885843f258571c45; __auc=b15c4507154c0e31047b3844aa7; _cb=CVUoIeDh7JhxCGgn1b; _chartbeat2=.1463525007080.1465845135479.0000000011110001; _ga=GA1.2.1272946403.1463524985; _gat=1; __utma=158138023.1272946403.1463524985.1466007370.1466019639.16; __utmb=158138023.0.10.1466019639; __utmc=158138023; __utmz=158138023.1465409755.13.3.utmcsr=facebook.com|utmccn=(referral)|utmcmd=referral|utmcct=/; __utmv=158138023.|1=custID=83f090439770a6e6cc0cb324504524e7=1' -H 'Origin: http://www.website.com' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: es-ES,es;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36' -H 'Content-type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: text/javascript, text/html, application/xml, text/xml, */*' -H 'X-Prototype-Version: 1.6.1' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Referer: http://www.website.com/resultadoBusqueda.html?q=KEYWORD2 --data 'action=searchSolr&type=CONTENT&siteCode=TEFURVJDRVJB&fq=taxonomyId%3A24%20AND%20status%3A2%20AND%20launchDate%3A%5B2008-05-31T23%3A59%3A59.999Z%20TO%20NOW%5D&indent=on&wt=json&qt=default&sort=launchDate%20desc&start=0&rows=1000&q=KEYWORD2&_=' --compressed >> MyFile.txt;
curl 'http://www.website.com/app/application' -H 'Cookie: _cb_ls=1; em_cdn_uid=t%3D1463525134354%26u%3D86461fb6689e46c4a62881ce3357cbcc; em_p_uid=l:1463668963788|t:1463525135884|u:f3d8947c76024450885843f258571c45; __auc=b15c4507154c0e31047b3844aa7; _cb=CVUoIeDh7JhxCGgn1b; _chartbeat2=.1463525007080.1465845135479.0000000011110001; _ga=GA1.2.1272946403.1463524985; _gat=1; __utma=158138023.1272946403.1463524985.1466007370.1466019639.16; __utmb=158138023.0.10.1466019639; __utmc=158138023; __utmz=158138023.1465409755.13.3.utmcsr=facebook.com|utmccn=(referral)|utmcmd=referral|utmcct=/; __utmv=158138023.|1=custID=83f090439770a6e6cc0cb324504524e7=1' -H 'Origin: http://www.website.com' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: es-ES,es;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36' -H 'Content-type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: text/javascript, text/html, application/xml, text/xml, */*' -H 'X-Prototype-Version: 1.6.1' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Referer: http://www.website.com/resultadoBusqueda.html?q=KEYWORD3 --data 'action=searchSolr&type=CONTENT&siteCode=TEFURVJDRVJB&fq=taxonomyId%3A24%20AND%20status%3A2%20AND%20launchDate%3A%5B2008-05-31T23%3A59%3A59.999Z%20TO%20NOW%5D&indent=on&wt=json&qt=default&sort=launchDate%20desc&start=0&rows=1000&q=KEYWORD3&_=' --compressed >> MyFile.txt;

之后,我复制了所有列,然后将其粘贴到控制台中。但查询的结果是:

-bash: syntax error near unexpected token `('

你知道问题是什么吗?

1 个答案:

答案 0 :(得分:2)

语法突出显示,无论是在编辑器中,还是在StackOverflow提供的后期,都会很快显示问题:

Syntax highlighted code showing unquoted literals

这里,所有标志都是一种颜色,而所有引用的参数都是另一种颜色,直到它们突然停止匹配。

仔细观察,您可以看到在--data之前的参数之前您错过了单引号。如果插入一个,语法高亮再次变得一致:

Syntax highlighted code corrected and consistently colored