如何在scapy中发送GET请求 [英] How do I send a GET request in scapy

查看:162
本文介绍了如何在scapy中发送GET请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我最近下载了一个linux ubuntu,我被要求发出一个请求,它将返回给我用户提供的邮政编码状态并发送到一个网站是在代码本身并打开状态。



因为某些奇怪的原因当我尝试运行代码时我写了它停在r = req.prepare()



这是在我下载请求moudle(sudo apt-get install python-pip)之后,假设是$ pip安装请求。



那么我需要做什么才能成功发送这个获取请求?







Hello there,
I recently downloaded a linux ubuntu, and I was asked to send out a request that will return me the state of a zip code given by the user and sent to a website that is in the code itself and pritn the state.

for some odd reason when I try to run the code I written it stopps at r = req.prepare()

And this is after I downloaded the request moudle (sudo apt-get install python-pip) which was suppose to be $ pip install requests.

So what do I need to do In order to send this get request successfuly?



from scapy.all import *
from random import randint
import requests
import urllib 








def main():

    

    
    

    for i in range(0,1):
        print "Please enter the mikud"
	#mikud = raw_input()
	address = r"http://www.uszip.com/zip/04966"
	#address+= mikud
	
	
        req = requests.Request('GET', address)
	r = req.prepare()
	s = requests.Session()
	back = s.send(r)
	
	print req
	print r
	print s
	print back
	
	
	
	if (req):
	    print "its real"
	    
	   

	else:
	    print "mikud is not real"

        




if __name__ == '__main__':
    main()

推荐答案

pip安装请求。



那么我需要做什么才能成功发送这个获取请求?







pip install requests.

So what do I need to do In order to send this get request successfuly?



from scapy.all import *
from random import randint
import requests
import urllib 








def main():

    

    
    

    for i in range(0,1):
        print "Please enter the mikud"
	#mikud = raw_input()
	address = r"http://www.uszip.com/zip/04966"
	#address+= mikud
	
	
        req = requests.Request('GET', address)
	r = req.prepare()
	s = requests.Session()
	back = s.send(r)
	
	print req
	print r
	print s
	print back
	
	
	
	if (req):
	    print "its real"
	    
	   

	else:
	    print "mikud is not real"

        




if __name__ == '__main__':
    main()


这篇关于如何在scapy中发送GET请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆