open a webpage with the same data as the response of a python requests script
up vote
0
down vote
favorite
import requests
session = requests.Session()
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.get('SomeWebsite').url
From this script I get an URL.
Just typing in the url wont work, because It doesnt have the same headers as In the response.
For Example If I go to www.example.com with the standard CF-RAY, I'll be redirected to A website www.example.com/No
If I go to www.example.com with the CF-RAY that I got from the response I'll be redirected to www.example.com/Yes
Bassicly In looking for something like this
session.get('SomeWebsite').OpenUrlInMyBrowser
Thanks alot!
Stefan
python python-2.7 python-requests
|
show 8 more comments
up vote
0
down vote
favorite
import requests
session = requests.Session()
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.get('SomeWebsite').url
From this script I get an URL.
Just typing in the url wont work, because It doesnt have the same headers as In the response.
For Example If I go to www.example.com with the standard CF-RAY, I'll be redirected to A website www.example.com/No
If I go to www.example.com with the CF-RAY that I got from the response I'll be redirected to www.example.com/Yes
Bassicly In looking for something like this
session.get('SomeWebsite').OpenUrlInMyBrowser
Thanks alot!
Stefan
python python-2.7 python-requests
Can you explain clearly what you want? Did you desire to get same response as browser? If true you need to post your example url, cause dynamic loading
– kcorlidy
Nov 8 at 3:03
@kcorlidy If I execute the scipt given, than I get an html code of the response. I bet there's a url option, but then I wont go to the website with the same response headers
– S. Known
Nov 8 at 7:48
You meansession.get('SomeWebsite').cookies? They have difference between response header and request header. Or you mean random header?
– kcorlidy
Nov 8 at 8:36
@kcorlidy It isnt just the cookies
– S. Known
Nov 8 at 9:27
@kcorlidy I updated the quistion, Did it help
– S. Known
Nov 8 at 9:33
|
show 8 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
import requests
session = requests.Session()
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.get('SomeWebsite').url
From this script I get an URL.
Just typing in the url wont work, because It doesnt have the same headers as In the response.
For Example If I go to www.example.com with the standard CF-RAY, I'll be redirected to A website www.example.com/No
If I go to www.example.com with the CF-RAY that I got from the response I'll be redirected to www.example.com/Yes
Bassicly In looking for something like this
session.get('SomeWebsite').OpenUrlInMyBrowser
Thanks alot!
Stefan
python python-2.7 python-requests
import requests
session = requests.Session()
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.headers.update({'Some headers'})
session.get('SomeWebsite').url
From this script I get an URL.
Just typing in the url wont work, because It doesnt have the same headers as In the response.
For Example If I go to www.example.com with the standard CF-RAY, I'll be redirected to A website www.example.com/No
If I go to www.example.com with the CF-RAY that I got from the response I'll be redirected to www.example.com/Yes
Bassicly In looking for something like this
session.get('SomeWebsite').OpenUrlInMyBrowser
Thanks alot!
Stefan
python python-2.7 python-requests
python python-2.7 python-requests
edited Nov 8 at 9:37
asked Nov 7 at 11:30
S. Known
25
25
Can you explain clearly what you want? Did you desire to get same response as browser? If true you need to post your example url, cause dynamic loading
– kcorlidy
Nov 8 at 3:03
@kcorlidy If I execute the scipt given, than I get an html code of the response. I bet there's a url option, but then I wont go to the website with the same response headers
– S. Known
Nov 8 at 7:48
You meansession.get('SomeWebsite').cookies? They have difference between response header and request header. Or you mean random header?
– kcorlidy
Nov 8 at 8:36
@kcorlidy It isnt just the cookies
– S. Known
Nov 8 at 9:27
@kcorlidy I updated the quistion, Did it help
– S. Known
Nov 8 at 9:33
|
show 8 more comments
Can you explain clearly what you want? Did you desire to get same response as browser? If true you need to post your example url, cause dynamic loading
– kcorlidy
Nov 8 at 3:03
@kcorlidy If I execute the scipt given, than I get an html code of the response. I bet there's a url option, but then I wont go to the website with the same response headers
– S. Known
Nov 8 at 7:48
You meansession.get('SomeWebsite').cookies? They have difference between response header and request header. Or you mean random header?
– kcorlidy
Nov 8 at 8:36
@kcorlidy It isnt just the cookies
– S. Known
Nov 8 at 9:27
@kcorlidy I updated the quistion, Did it help
– S. Known
Nov 8 at 9:33
Can you explain clearly what you want? Did you desire to get same response as browser? If true you need to post your example url, cause dynamic loading
– kcorlidy
Nov 8 at 3:03
Can you explain clearly what you want? Did you desire to get same response as browser? If true you need to post your example url, cause dynamic loading
– kcorlidy
Nov 8 at 3:03
@kcorlidy If I execute the scipt given, than I get an html code of the response. I bet there's a url option, but then I wont go to the website with the same response headers
– S. Known
Nov 8 at 7:48
@kcorlidy If I execute the scipt given, than I get an html code of the response. I bet there's a url option, but then I wont go to the website with the same response headers
– S. Known
Nov 8 at 7:48
You mean
session.get('SomeWebsite').cookies ? They have difference between response header and request header. Or you mean random header?– kcorlidy
Nov 8 at 8:36
You mean
session.get('SomeWebsite').cookies ? They have difference between response header and request header. Or you mean random header?– kcorlidy
Nov 8 at 8:36
@kcorlidy It isnt just the cookies
– S. Known
Nov 8 at 9:27
@kcorlidy It isnt just the cookies
– S. Known
Nov 8 at 9:27
@kcorlidy I updated the quistion, Did it help
– S. Known
Nov 8 at 9:33
@kcorlidy I updated the quistion, Did it help
– S. Known
Nov 8 at 9:33
|
show 8 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
Not sure if this helps, I still don't completely understand your question.
You can display the headers of the response you get using:
session.get('SomeWebsite').headers
and include those in a new request. You could do this with a blanket:
response = session.get("http://www.example.com")
session2 = requests.Session()
session2.headers.update(response.headers)
but this doesn't make much sense because the defined headers for requests and responses are not the same. So you have to manually select the properties you want.
If you are not sure which properties you need this will tell you how to show all the info from a request.
This is how you open a URL in your browser
import webbrowser
webbrowser.open_new("http://www.example.com")
Did you ever see you request header with this code? Mr. You are doing something terrible
– kcorlidy
Nov 8 at 10:00
@kcorlidy What is your question?
– Pumpkin
Nov 8 at 10:02
I think you should try your code and see your request content, which contains lots of it should not have, likeStatus
– kcorlidy
Nov 8 at 10:04
@kcorlidy I just want to open the response in my browser
– S. Known
Nov 8 at 10:56
@S.Known I added how to open a URL in your browser. Is that what you are looking for? It does, however, not allow you to edit the header.
– Pumpkin
Nov 8 at 11:45
|
show 2 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Not sure if this helps, I still don't completely understand your question.
You can display the headers of the response you get using:
session.get('SomeWebsite').headers
and include those in a new request. You could do this with a blanket:
response = session.get("http://www.example.com")
session2 = requests.Session()
session2.headers.update(response.headers)
but this doesn't make much sense because the defined headers for requests and responses are not the same. So you have to manually select the properties you want.
If you are not sure which properties you need this will tell you how to show all the info from a request.
This is how you open a URL in your browser
import webbrowser
webbrowser.open_new("http://www.example.com")
Did you ever see you request header with this code? Mr. You are doing something terrible
– kcorlidy
Nov 8 at 10:00
@kcorlidy What is your question?
– Pumpkin
Nov 8 at 10:02
I think you should try your code and see your request content, which contains lots of it should not have, likeStatus
– kcorlidy
Nov 8 at 10:04
@kcorlidy I just want to open the response in my browser
– S. Known
Nov 8 at 10:56
@S.Known I added how to open a URL in your browser. Is that what you are looking for? It does, however, not allow you to edit the header.
– Pumpkin
Nov 8 at 11:45
|
show 2 more comments
up vote
0
down vote
Not sure if this helps, I still don't completely understand your question.
You can display the headers of the response you get using:
session.get('SomeWebsite').headers
and include those in a new request. You could do this with a blanket:
response = session.get("http://www.example.com")
session2 = requests.Session()
session2.headers.update(response.headers)
but this doesn't make much sense because the defined headers for requests and responses are not the same. So you have to manually select the properties you want.
If you are not sure which properties you need this will tell you how to show all the info from a request.
This is how you open a URL in your browser
import webbrowser
webbrowser.open_new("http://www.example.com")
Did you ever see you request header with this code? Mr. You are doing something terrible
– kcorlidy
Nov 8 at 10:00
@kcorlidy What is your question?
– Pumpkin
Nov 8 at 10:02
I think you should try your code and see your request content, which contains lots of it should not have, likeStatus
– kcorlidy
Nov 8 at 10:04
@kcorlidy I just want to open the response in my browser
– S. Known
Nov 8 at 10:56
@S.Known I added how to open a URL in your browser. Is that what you are looking for? It does, however, not allow you to edit the header.
– Pumpkin
Nov 8 at 11:45
|
show 2 more comments
up vote
0
down vote
up vote
0
down vote
Not sure if this helps, I still don't completely understand your question.
You can display the headers of the response you get using:
session.get('SomeWebsite').headers
and include those in a new request. You could do this with a blanket:
response = session.get("http://www.example.com")
session2 = requests.Session()
session2.headers.update(response.headers)
but this doesn't make much sense because the defined headers for requests and responses are not the same. So you have to manually select the properties you want.
If you are not sure which properties you need this will tell you how to show all the info from a request.
This is how you open a URL in your browser
import webbrowser
webbrowser.open_new("http://www.example.com")
Not sure if this helps, I still don't completely understand your question.
You can display the headers of the response you get using:
session.get('SomeWebsite').headers
and include those in a new request. You could do this with a blanket:
response = session.get("http://www.example.com")
session2 = requests.Session()
session2.headers.update(response.headers)
but this doesn't make much sense because the defined headers for requests and responses are not the same. So you have to manually select the properties you want.
If you are not sure which properties you need this will tell you how to show all the info from a request.
This is how you open a URL in your browser
import webbrowser
webbrowser.open_new("http://www.example.com")
edited Nov 8 at 11:44
answered Nov 8 at 9:52
Pumpkin
537
537
Did you ever see you request header with this code? Mr. You are doing something terrible
– kcorlidy
Nov 8 at 10:00
@kcorlidy What is your question?
– Pumpkin
Nov 8 at 10:02
I think you should try your code and see your request content, which contains lots of it should not have, likeStatus
– kcorlidy
Nov 8 at 10:04
@kcorlidy I just want to open the response in my browser
– S. Known
Nov 8 at 10:56
@S.Known I added how to open a URL in your browser. Is that what you are looking for? It does, however, not allow you to edit the header.
– Pumpkin
Nov 8 at 11:45
|
show 2 more comments
Did you ever see you request header with this code? Mr. You are doing something terrible
– kcorlidy
Nov 8 at 10:00
@kcorlidy What is your question?
– Pumpkin
Nov 8 at 10:02
I think you should try your code and see your request content, which contains lots of it should not have, likeStatus
– kcorlidy
Nov 8 at 10:04
@kcorlidy I just want to open the response in my browser
– S. Known
Nov 8 at 10:56
@S.Known I added how to open a URL in your browser. Is that what you are looking for? It does, however, not allow you to edit the header.
– Pumpkin
Nov 8 at 11:45
Did you ever see you request header with this code? Mr. You are doing something terrible
– kcorlidy
Nov 8 at 10:00
Did you ever see you request header with this code? Mr. You are doing something terrible
– kcorlidy
Nov 8 at 10:00
@kcorlidy What is your question?
– Pumpkin
Nov 8 at 10:02
@kcorlidy What is your question?
– Pumpkin
Nov 8 at 10:02
I think you should try your code and see your request content, which contains lots of it should not have, like
Status– kcorlidy
Nov 8 at 10:04
I think you should try your code and see your request content, which contains lots of it should not have, like
Status– kcorlidy
Nov 8 at 10:04
@kcorlidy I just want to open the response in my browser
– S. Known
Nov 8 at 10:56
@kcorlidy I just want to open the response in my browser
– S. Known
Nov 8 at 10:56
@S.Known I added how to open a URL in your browser. Is that what you are looking for? It does, however, not allow you to edit the header.
– Pumpkin
Nov 8 at 11:45
@S.Known I added how to open a URL in your browser. Is that what you are looking for? It does, however, not allow you to edit the header.
– Pumpkin
Nov 8 at 11:45
|
show 2 more comments
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53188618%2fopen-a-webpage-with-the-same-data-as-the-response-of-a-python-requests-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Can you explain clearly what you want? Did you desire to get same response as browser? If true you need to post your example url, cause dynamic loading
– kcorlidy
Nov 8 at 3:03
@kcorlidy If I execute the scipt given, than I get an html code of the response. I bet there's a url option, but then I wont go to the website with the same response headers
– S. Known
Nov 8 at 7:48
You mean
session.get('SomeWebsite').cookies? They have difference between response header and request header. Or you mean random header?– kcorlidy
Nov 8 at 8:36
@kcorlidy It isnt just the cookies
– S. Known
Nov 8 at 9:27
@kcorlidy I updated the quistion, Did it help
– S. Known
Nov 8 at 9:33