[英]Send Thousands of Post Data to Page using Python?
import urllib,urllib2
for x in range(0, 10000):
url = '127.0.0.1/post.php'
parameters = {'id' : '5'}
data = urllib.urlencode(parameters) # Use urllib to encode the parameters
request = urllib2.Request(url, data)
response = urllib2.urlopen(request) # This request is sent in HTTP POST
page = response.read(1)
print x
我有一個循環的基本腳本。 但是是否可以快速將數千個帖子數據發送到頁面?
我是新來的。 請指教。
謝謝
import requests
url = 'http://192.168.2.1/'
count = 0
for i in range(1,10):
source_code = requests.get(url)
if source_code.status_code == 200:
count +=1
print(count)
輸出:C:\\ Python34 \\ python.exe“ E:/ python study / Multiple request.py” 1 2 3 4 5 6 7 8 9
如果您希望它執行負載測試,那么可能會選擇JMeter,我過去使用過它,使用起來很簡單。
我建議不要嘗試重新發明輪子,而是尋找一種可以幫助您完成任務的負載測試工具。 例如, Locust和Taurus測試框架是基於Python的。
其他免費和開源的負載測試工具是:
請參閱開源負載測試工具:您應該使用哪一個? 該指南包含樣本測試,負載報告和功能比較矩陣,希望您會找到正確的選擇。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.