【发布时间】:2018-11-22 09:21:29
【问题描述】:
我已经编写了这段代码,它应该上传一些东西,但它不上传任何东西,只是在我的控制台中打印命令的结果,并且不上传任何东西到网站
import requests, os, re, subprocess
from bs4 import BeautifulSoup
command = 'netsh interface ip show addresses "Ethernet" | findstr /c:IP'
outcome = str(subprocess.Popen(command, shell=True).wait())
#soup = BeautifulSoup(outcome,'lxml')
#outcome = outcome.replace('0','')
#print str(subprocess.call(command, shell=True))
requests.post("example.com", {'field1': outcome})
和控制台输出:
IP Address: 192.168.1.23
上传到网站0
我试过了:
import requests, os, re, subprocess
from bs4 import BeautifulSoup
command = 'netsh interface ip show addresses "Ethernet" | findstr /c:IP'
#subprocess.communicate(command, shell=True)
subprocess.Popen(command, shell=True).communicate()
outcome = subprocess.PIPE
#soup = BeautifulSoup(outcome,'lxml')
#outcome = outcome.replace('0','')
#print str(subprocess.call(command, shell=True))
requests.post("example.com", {'field1': outcome})
和控制台输出:
IP Address: 192.168.1.23
哪些上传到网站-1
我想要它做的是将该 IP 地址结果上传到网站。
【问题讨论】:
-
此代码中的任何内容都不应打印我能看到的任何内容。如何获得“成果”?
-
@roganjosh 好吧,它应该将结果上传到网站,但它会在我执行脚本的控制台中打印它。如果有什么不同,我正在使用 python2.7
-
@roganjosh 我编辑了问题,请看看你能做什么
标签: python python-2.7 python-requests