How to do multi post in Python?How do I check whether a file exists without exceptions?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?PUT vs. POST in RESTDoes Python have a string 'contains' substring method?

Check if a string is entirely made of the same substring

How can I print the prosodic symbols in LaTeX?

Pre-plastic human skin alternative

How to have a sharp product image?

"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?

How can I get this effect? Please see the attached image

Checks user level and limit the data before saving it to mongoDB

Why did C use the -> operator instead of reusing the . operator?

a sore throat vs a strep throat vs strep throat

"The cow" OR "a cow" OR "cows" in this context

What are the steps to solving this definite integral?

Can't get 5V 3A DC constant

What happened to Captain America in Endgame?

Why do games have consumables?

Mistake in years of experience in resume?

How can I practically buy stocks?

Is the claim "Employers won't employ people with no 'social media presence'" realistic?

Rivers without rain

Is there any official lore on the Far Realm?

Why was the Spitfire's elliptical wing almost uncopied by other aircraft of World War 2?

Multiple options vs single option UI

How to limit Drive Letters Windows assigns to new removable USB drives

Function pointer with named arguments?

How come there are so many candidates for the 2020 Democratic party presidential nomination?



How to do multi post in Python?


How do I check whether a file exists without exceptions?Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?PUT vs. POST in RESTDoes Python have a string 'contains' substring method?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-2















I want my python post faster , and make it multithreading






# Data SET
env = "PROD"
accNameLocked = env
accountPassword = "ddd"
appIdKey = "3b356c1bac5ad9735ad62f24d43414eb59715cc4d21b178835626ce0d2daa77d"
fdcBrowserData = ""
language = "US-EN"
openiForgotInNewWindow = "true"
path = "/"
requestUri = "/login.html"
rv = "1"
scnt = "31b0020ec593370dc388f8965e"
view = "5"
Mode_File = "r+"
open_file = open(appleId,Mode_File)
read_me = open_file.readlines()
for i in read_me:
i.strip()
get_data = tPassword,"appIdKey":appIdKey,"appleId":i,"fdcBrowserData":fdcBrndowuestUri":requestUri,"rv":rv,"scnt":scnt,"view":view
connect = p.post(url,params=get_data).content
valid_msg = "YAY"
dia_msg = "Hey"
if (valid_msg in connect):
print("Valid :>> "+i)
save_valid = open("rzlt/live.txt","a+")
save_valid.write("n"+i)
elif(dia_msg in connect):
print("Die :>> "+i)
save_invalid = open("rzlt/die.txt","a+")
save_invalid.write("n"+i)





how to make it multiposting?, thanks alot so it gonna post the url faster, because the normal run is only one by one










share|improve this question






















  • Do you know if the server has some kind of rate-limitting? Because if it does, then concurrent requests may not help you there because the server will just block the new connections.

    – Ralf
    Mar 9 at 11:10

















-2















I want my python post faster , and make it multithreading






# Data SET
env = "PROD"
accNameLocked = env
accountPassword = "ddd"
appIdKey = "3b356c1bac5ad9735ad62f24d43414eb59715cc4d21b178835626ce0d2daa77d"
fdcBrowserData = ""
language = "US-EN"
openiForgotInNewWindow = "true"
path = "/"
requestUri = "/login.html"
rv = "1"
scnt = "31b0020ec593370dc388f8965e"
view = "5"
Mode_File = "r+"
open_file = open(appleId,Mode_File)
read_me = open_file.readlines()
for i in read_me:
i.strip()
get_data = tPassword,"appIdKey":appIdKey,"appleId":i,"fdcBrowserData":fdcBrndowuestUri":requestUri,"rv":rv,"scnt":scnt,"view":view
connect = p.post(url,params=get_data).content
valid_msg = "YAY"
dia_msg = "Hey"
if (valid_msg in connect):
print("Valid :>> "+i)
save_valid = open("rzlt/live.txt","a+")
save_valid.write("n"+i)
elif(dia_msg in connect):
print("Die :>> "+i)
save_invalid = open("rzlt/die.txt","a+")
save_invalid.write("n"+i)





how to make it multiposting?, thanks alot so it gonna post the url faster, because the normal run is only one by one










share|improve this question






















  • Do you know if the server has some kind of rate-limitting? Because if it does, then concurrent requests may not help you there because the server will just block the new connections.

    – Ralf
    Mar 9 at 11:10













-2












-2








-2








I want my python post faster , and make it multithreading






# Data SET
env = "PROD"
accNameLocked = env
accountPassword = "ddd"
appIdKey = "3b356c1bac5ad9735ad62f24d43414eb59715cc4d21b178835626ce0d2daa77d"
fdcBrowserData = ""
language = "US-EN"
openiForgotInNewWindow = "true"
path = "/"
requestUri = "/login.html"
rv = "1"
scnt = "31b0020ec593370dc388f8965e"
view = "5"
Mode_File = "r+"
open_file = open(appleId,Mode_File)
read_me = open_file.readlines()
for i in read_me:
i.strip()
get_data = tPassword,"appIdKey":appIdKey,"appleId":i,"fdcBrowserData":fdcBrndowuestUri":requestUri,"rv":rv,"scnt":scnt,"view":view
connect = p.post(url,params=get_data).content
valid_msg = "YAY"
dia_msg = "Hey"
if (valid_msg in connect):
print("Valid :>> "+i)
save_valid = open("rzlt/live.txt","a+")
save_valid.write("n"+i)
elif(dia_msg in connect):
print("Die :>> "+i)
save_invalid = open("rzlt/die.txt","a+")
save_invalid.write("n"+i)





how to make it multiposting?, thanks alot so it gonna post the url faster, because the normal run is only one by one










share|improve this question














I want my python post faster , and make it multithreading






# Data SET
env = "PROD"
accNameLocked = env
accountPassword = "ddd"
appIdKey = "3b356c1bac5ad9735ad62f24d43414eb59715cc4d21b178835626ce0d2daa77d"
fdcBrowserData = ""
language = "US-EN"
openiForgotInNewWindow = "true"
path = "/"
requestUri = "/login.html"
rv = "1"
scnt = "31b0020ec593370dc388f8965e"
view = "5"
Mode_File = "r+"
open_file = open(appleId,Mode_File)
read_me = open_file.readlines()
for i in read_me:
i.strip()
get_data = tPassword,"appIdKey":appIdKey,"appleId":i,"fdcBrowserData":fdcBrndowuestUri":requestUri,"rv":rv,"scnt":scnt,"view":view
connect = p.post(url,params=get_data).content
valid_msg = "YAY"
dia_msg = "Hey"
if (valid_msg in connect):
print("Valid :>> "+i)
save_valid = open("rzlt/live.txt","a+")
save_valid.write("n"+i)
elif(dia_msg in connect):
print("Die :>> "+i)
save_invalid = open("rzlt/die.txt","a+")
save_invalid.write("n"+i)





how to make it multiposting?, thanks alot so it gonna post the url faster, because the normal run is only one by one






# Data SET
env = "PROD"
accNameLocked = env
accountPassword = "ddd"
appIdKey = "3b356c1bac5ad9735ad62f24d43414eb59715cc4d21b178835626ce0d2daa77d"
fdcBrowserData = ""
language = "US-EN"
openiForgotInNewWindow = "true"
path = "/"
requestUri = "/login.html"
rv = "1"
scnt = "31b0020ec593370dc388f8965e"
view = "5"
Mode_File = "r+"
open_file = open(appleId,Mode_File)
read_me = open_file.readlines()
for i in read_me:
i.strip()
get_data = tPassword,"appIdKey":appIdKey,"appleId":i,"fdcBrowserData":fdcBrndowuestUri":requestUri,"rv":rv,"scnt":scnt,"view":view
connect = p.post(url,params=get_data).content
valid_msg = "YAY"
dia_msg = "Hey"
if (valid_msg in connect):
print("Valid :>> "+i)
save_valid = open("rzlt/live.txt","a+")
save_valid.write("n"+i)
elif(dia_msg in connect):
print("Die :>> "+i)
save_invalid = open("rzlt/die.txt","a+")
save_invalid.write("n"+i)





# Data SET
env = "PROD"
accNameLocked = env
accountPassword = "ddd"
appIdKey = "3b356c1bac5ad9735ad62f24d43414eb59715cc4d21b178835626ce0d2daa77d"
fdcBrowserData = ""
language = "US-EN"
openiForgotInNewWindow = "true"
path = "/"
requestUri = "/login.html"
rv = "1"
scnt = "31b0020ec593370dc388f8965e"
view = "5"
Mode_File = "r+"
open_file = open(appleId,Mode_File)
read_me = open_file.readlines()
for i in read_me:
i.strip()
get_data = tPassword,"appIdKey":appIdKey,"appleId":i,"fdcBrowserData":fdcBrndowuestUri":requestUri,"rv":rv,"scnt":scnt,"view":view
connect = p.post(url,params=get_data).content
valid_msg = "YAY"
dia_msg = "Hey"
if (valid_msg in connect):
print("Valid :>> "+i)
save_valid = open("rzlt/live.txt","a+")
save_valid.write("n"+i)
elif(dia_msg in connect):
print("Die :>> "+i)
save_invalid = open("rzlt/die.txt","a+")
save_invalid.write("n"+i)






python post






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 9 at 8:56









Cahya Darma WijayaCahya Darma Wijaya

236




236












  • Do you know if the server has some kind of rate-limitting? Because if it does, then concurrent requests may not help you there because the server will just block the new connections.

    – Ralf
    Mar 9 at 11:10

















  • Do you know if the server has some kind of rate-limitting? Because if it does, then concurrent requests may not help you there because the server will just block the new connections.

    – Ralf
    Mar 9 at 11:10
















Do you know if the server has some kind of rate-limitting? Because if it does, then concurrent requests may not help you there because the server will just block the new connections.

– Ralf
Mar 9 at 11:10





Do you know if the server has some kind of rate-limitting? Because if it does, then concurrent requests may not help you there because the server will just block the new connections.

– Ralf
Mar 9 at 11:10












1 Answer
1






active

oldest

votes


















0














Well, here are several suggestions to fix some issues with your code:



  • you are never closing the files that you open; you should always close them explicitly (or use with open() as f:, which closes them automatically).


  • i.strip() returns a new string, but you are not using it; you need to assign the return value to a variable, probably i = i.strip().

  • you can use for line in f: to iterate over the lines in the opened file one by one instead of using f.readlines(); my suggestion reads from the file as the content is needed, it does not read all at once into memory.

  • your variable called get_data is not a valid dict.

Also, you do not show your imports, so I don't know what lib you use to make the HTTP requests, and you also never defined some variables that you used.



Nevertheless here is a slightly improved version of your code:



with open('your-filename.txt', "r+") as f,
open("rzlt/live.txt", "a+") as f_valid,
open("rzlt/die.txt", "a+") as f_invalid:

for line in f:
line = line.strip()
if len(line) > 0: # avoid empty lines
data =
"appleId": line,
"appIdKey": appIdKey,
"fdcBrowserData": fdcBrowserData,
"requestUri": requestUri,
"rv": rv,
"scnt": scnt,
"view": view,

response_content = p.post(url, params=data).content

if "YAY" in response_content:
print("Valid :>> ", line)
f_valid.write("n".format(line))
elif "Hey" in response_content:
print("Invalid :>> ", line)
f_invalid.write("n".format(line))





share|improve this answer























  • i want my script execute response_content = p.post(url,params=get_data).content multiple so it faster showing the result

    – Cahya Darma Wijaya
    Mar 9 at 13:04











  • ok, what data type is p ?

    – Ralf
    Mar 9 at 13:07











  • @CahyaDarmaWijaya have you looked into the documentation of Pythons threading and multiprocessing modules?

    – Ralf
    Mar 9 at 13:07











  • import requests as p, i had looked the threading and multiprocessing getting confuse where i have to place it

    – Cahya Darma Wijaya
    Mar 9 at 13:10











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55075618%2fhow-to-do-multi-post-in-python%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Well, here are several suggestions to fix some issues with your code:



  • you are never closing the files that you open; you should always close them explicitly (or use with open() as f:, which closes them automatically).


  • i.strip() returns a new string, but you are not using it; you need to assign the return value to a variable, probably i = i.strip().

  • you can use for line in f: to iterate over the lines in the opened file one by one instead of using f.readlines(); my suggestion reads from the file as the content is needed, it does not read all at once into memory.

  • your variable called get_data is not a valid dict.

Also, you do not show your imports, so I don't know what lib you use to make the HTTP requests, and you also never defined some variables that you used.



Nevertheless here is a slightly improved version of your code:



with open('your-filename.txt', "r+") as f,
open("rzlt/live.txt", "a+") as f_valid,
open("rzlt/die.txt", "a+") as f_invalid:

for line in f:
line = line.strip()
if len(line) > 0: # avoid empty lines
data =
"appleId": line,
"appIdKey": appIdKey,
"fdcBrowserData": fdcBrowserData,
"requestUri": requestUri,
"rv": rv,
"scnt": scnt,
"view": view,

response_content = p.post(url, params=data).content

if "YAY" in response_content:
print("Valid :>> ", line)
f_valid.write("n".format(line))
elif "Hey" in response_content:
print("Invalid :>> ", line)
f_invalid.write("n".format(line))





share|improve this answer























  • i want my script execute response_content = p.post(url,params=get_data).content multiple so it faster showing the result

    – Cahya Darma Wijaya
    Mar 9 at 13:04











  • ok, what data type is p ?

    – Ralf
    Mar 9 at 13:07











  • @CahyaDarmaWijaya have you looked into the documentation of Pythons threading and multiprocessing modules?

    – Ralf
    Mar 9 at 13:07











  • import requests as p, i had looked the threading and multiprocessing getting confuse where i have to place it

    – Cahya Darma Wijaya
    Mar 9 at 13:10















0














Well, here are several suggestions to fix some issues with your code:



  • you are never closing the files that you open; you should always close them explicitly (or use with open() as f:, which closes them automatically).


  • i.strip() returns a new string, but you are not using it; you need to assign the return value to a variable, probably i = i.strip().

  • you can use for line in f: to iterate over the lines in the opened file one by one instead of using f.readlines(); my suggestion reads from the file as the content is needed, it does not read all at once into memory.

  • your variable called get_data is not a valid dict.

Also, you do not show your imports, so I don't know what lib you use to make the HTTP requests, and you also never defined some variables that you used.



Nevertheless here is a slightly improved version of your code:



with open('your-filename.txt', "r+") as f,
open("rzlt/live.txt", "a+") as f_valid,
open("rzlt/die.txt", "a+") as f_invalid:

for line in f:
line = line.strip()
if len(line) > 0: # avoid empty lines
data =
"appleId": line,
"appIdKey": appIdKey,
"fdcBrowserData": fdcBrowserData,
"requestUri": requestUri,
"rv": rv,
"scnt": scnt,
"view": view,

response_content = p.post(url, params=data).content

if "YAY" in response_content:
print("Valid :>> ", line)
f_valid.write("n".format(line))
elif "Hey" in response_content:
print("Invalid :>> ", line)
f_invalid.write("n".format(line))





share|improve this answer























  • i want my script execute response_content = p.post(url,params=get_data).content multiple so it faster showing the result

    – Cahya Darma Wijaya
    Mar 9 at 13:04











  • ok, what data type is p ?

    – Ralf
    Mar 9 at 13:07











  • @CahyaDarmaWijaya have you looked into the documentation of Pythons threading and multiprocessing modules?

    – Ralf
    Mar 9 at 13:07











  • import requests as p, i had looked the threading and multiprocessing getting confuse where i have to place it

    – Cahya Darma Wijaya
    Mar 9 at 13:10













0












0








0







Well, here are several suggestions to fix some issues with your code:



  • you are never closing the files that you open; you should always close them explicitly (or use with open() as f:, which closes them automatically).


  • i.strip() returns a new string, but you are not using it; you need to assign the return value to a variable, probably i = i.strip().

  • you can use for line in f: to iterate over the lines in the opened file one by one instead of using f.readlines(); my suggestion reads from the file as the content is needed, it does not read all at once into memory.

  • your variable called get_data is not a valid dict.

Also, you do not show your imports, so I don't know what lib you use to make the HTTP requests, and you also never defined some variables that you used.



Nevertheless here is a slightly improved version of your code:



with open('your-filename.txt', "r+") as f,
open("rzlt/live.txt", "a+") as f_valid,
open("rzlt/die.txt", "a+") as f_invalid:

for line in f:
line = line.strip()
if len(line) > 0: # avoid empty lines
data =
"appleId": line,
"appIdKey": appIdKey,
"fdcBrowserData": fdcBrowserData,
"requestUri": requestUri,
"rv": rv,
"scnt": scnt,
"view": view,

response_content = p.post(url, params=data).content

if "YAY" in response_content:
print("Valid :>> ", line)
f_valid.write("n".format(line))
elif "Hey" in response_content:
print("Invalid :>> ", line)
f_invalid.write("n".format(line))





share|improve this answer













Well, here are several suggestions to fix some issues with your code:



  • you are never closing the files that you open; you should always close them explicitly (or use with open() as f:, which closes them automatically).


  • i.strip() returns a new string, but you are not using it; you need to assign the return value to a variable, probably i = i.strip().

  • you can use for line in f: to iterate over the lines in the opened file one by one instead of using f.readlines(); my suggestion reads from the file as the content is needed, it does not read all at once into memory.

  • your variable called get_data is not a valid dict.

Also, you do not show your imports, so I don't know what lib you use to make the HTTP requests, and you also never defined some variables that you used.



Nevertheless here is a slightly improved version of your code:



with open('your-filename.txt', "r+") as f,
open("rzlt/live.txt", "a+") as f_valid,
open("rzlt/die.txt", "a+") as f_invalid:

for line in f:
line = line.strip()
if len(line) > 0: # avoid empty lines
data =
"appleId": line,
"appIdKey": appIdKey,
"fdcBrowserData": fdcBrowserData,
"requestUri": requestUri,
"rv": rv,
"scnt": scnt,
"view": view,

response_content = p.post(url, params=data).content

if "YAY" in response_content:
print("Valid :>> ", line)
f_valid.write("n".format(line))
elif "Hey" in response_content:
print("Invalid :>> ", line)
f_invalid.write("n".format(line))






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 9 at 11:09









RalfRalf

7,55341438




7,55341438












  • i want my script execute response_content = p.post(url,params=get_data).content multiple so it faster showing the result

    – Cahya Darma Wijaya
    Mar 9 at 13:04











  • ok, what data type is p ?

    – Ralf
    Mar 9 at 13:07











  • @CahyaDarmaWijaya have you looked into the documentation of Pythons threading and multiprocessing modules?

    – Ralf
    Mar 9 at 13:07











  • import requests as p, i had looked the threading and multiprocessing getting confuse where i have to place it

    – Cahya Darma Wijaya
    Mar 9 at 13:10

















  • i want my script execute response_content = p.post(url,params=get_data).content multiple so it faster showing the result

    – Cahya Darma Wijaya
    Mar 9 at 13:04











  • ok, what data type is p ?

    – Ralf
    Mar 9 at 13:07











  • @CahyaDarmaWijaya have you looked into the documentation of Pythons threading and multiprocessing modules?

    – Ralf
    Mar 9 at 13:07











  • import requests as p, i had looked the threading and multiprocessing getting confuse where i have to place it

    – Cahya Darma Wijaya
    Mar 9 at 13:10
















i want my script execute response_content = p.post(url,params=get_data).content multiple so it faster showing the result

– Cahya Darma Wijaya
Mar 9 at 13:04





i want my script execute response_content = p.post(url,params=get_data).content multiple so it faster showing the result

– Cahya Darma Wijaya
Mar 9 at 13:04













ok, what data type is p ?

– Ralf
Mar 9 at 13:07





ok, what data type is p ?

– Ralf
Mar 9 at 13:07













@CahyaDarmaWijaya have you looked into the documentation of Pythons threading and multiprocessing modules?

– Ralf
Mar 9 at 13:07





@CahyaDarmaWijaya have you looked into the documentation of Pythons threading and multiprocessing modules?

– Ralf
Mar 9 at 13:07













import requests as p, i had looked the threading and multiprocessing getting confuse where i have to place it

– Cahya Darma Wijaya
Mar 9 at 13:10





import requests as p, i had looked the threading and multiprocessing getting confuse where i have to place it

– Cahya Darma Wijaya
Mar 9 at 13:10



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55075618%2fhow-to-do-multi-post-in-python%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович