简体   繁体   English

如何加快这个curl脚本并更快地响应

[英]How to speed up this curl script and response faster

I do have this script to get some variables hitting a server. 我确实有此脚本来获取某些变量到达服务器。 The point is that is doing it slow and I have to run multiple times same script to get a decent rate of requests. 关键是这样做的速度很慢,我必须多次运行同一脚本才能获得不错的请求率。 How can I multiply number of threads with this curl script without needing to run it 4 or 5 times? 如何使用此curl脚本将线程数相乘而不需要运行4或5次?

Also I would like to make it faster and performed, this is original one 我也想使它更快和执行,这是原始的

    while ! grep "TokenException" output.txt > /dev/null
do
echo -e '\n'$(date +%x_%H:%M:%S:%3N) > output.txt
curl -s -H 'Host: host.com' -H "Cookie: session-token="$SESSION\" -H "x-amz-access-token: $token" -H "x-flex-instance-id: $flex" -H 'Accept: */*' -H 'User-Agent: Dalvik/2.1.0 (Linux; U; Android 7.1.1; Nexus 5X Build/N4F26T) RabbitAndroid/3.0.6778.0' -H 'Accept-Language: en-us' --compressed 'https://hostname.com/GetOffersForProvider?serviceAreaIds=16' >> output.txt
if grep -q "OFFERED" output.txt; then
    cat output.txt >> foundb.txt

      ./getlast.bat

    if [ ! -f pageflag.txt ]; then
         /usr/bin/php alert.php
        echo "paged" > pageflag.txt
    fi
sleep 0.05
fi
done

I modified to 我修改为

while ! grep "TokenException" output.txt > /dev/null
do
echo -e '\n'$(date +%x_%H:%M:%S:%3N) > output.txt
curl -s -H 'Host: host.com' -H "Cookie: session-token="$SESSION\" -H "x-amz-access-token: $token" -H "x-flex-instance-id: $flex" -H 'Accept: */*' -H 'User-Agent: Dalvik/2.1.0 (Linux; U; Android 7.1.1; Nexus 5X Build/N4F26T) RabbitAndroid/3.0.6778.0' -H 'Accept-Language: en-us' --compressed 'https://hostname.com/GetOffersForProvider?serviceAreaIds=16' >> output.txt
if grep -q "OFFERED" output.txt; then
    cat output.txt >> foundb.txt

  ./getlast.bat

         /usr/bin/php alert.php
sleep 0.05
fi
done

Some suggestion to run on multi threading and faster even with sleep or another way to pause for milliseconds instead? 一些建议即使在睡眠或以其他方式暂停几毫秒的情况下也可以在多线程上更快地运行? Main point is that it should execute ./getlast.bat as fast as possible with variables caught from curl, but it has a time difference between data and getlast.bat execution of 2 seconds, too much 要点是它应该使用curl捕获的变量尽可能快地执行./getlast.bat,但是数据和getlast.bat执行之间的时间差为2秒,太多了

curl itself doesn't support multiple connections/threads and/or resume cancelled/stalled operations. curl本身不支持多个连接/线程和/或恢复已取消/已停止的操作。

Use aria2 or something similar. 使用aria2或类似的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM