Comments (2)
Hi @KenKout, can you please supply the full set of information requested in the ticket template and the complete stacktrace?
What's provided currently is not reproducible.
This works as expected:
import requests
r = requests.get('https://httpbin.org/redirect-to?url=app://test', allow_redirects=False)
From the error, it looks like the location is being parsed at some point, it's not clear where that's happening.
from requests.
import requests
from requests.structures import CaseInsensitiveDict
url = "https://sandbox.moodledemo.net/login/index.php"
s = requests.Session()
headers = CaseInsensitiveDict()
headers["Content-Type"] = "application/x-www-form-urlencoded"
headers["Origin"] = "https://sandbox.moodledemo.net"
headers["Referer"] = "https://sandbox.moodledemo.net/login/index.php"
headers["User-Agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0"
resp = s.get(url, headers=headers)
logintoken = resp.text.split('logintoken" value="')[1].split('"')[0]
data = f"anchor=&logintoken={logintoken}&username=admin&password=sandbox"
resp = s.post(url, headers=headers, data=data)
print(resp.text)
url = 'https://sandbox.moodledemo.net/admin/tool/mobile/launch.php?service=moodle_mobile_app&passport=1&urlscheme=moodlemobile'
resp = s.get(url, headers=headers)
print(resp.text)
Hi, this is the script, sorry for late response
It works well when I use library httpx
import requests
from requests.structures import CaseInsensitiveDict
url = "https://sandbox.moodledemo.net/login/index.php"
s = requests.Session()
headers = CaseInsensitiveDict()
headers["Content-Type"] = "application/x-www-form-urlencoded"
headers["Origin"] = "https://sandbox.moodledemo.net"
headers["Referer"] = "https://sandbox.moodledemo.net/login/index.php"
headers["User-Agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0"
resp = s.get(url, headers=headers)
logintoken = resp.text.split('logintoken" value="')[1].split('"')[0]
data = f"anchor=&logintoken={logintoken}&username=admin&password=sandbox"
resp = s.post(url, headers=headers, data=data)
print(resp.text)
import httpx
url = 'https://sandbox.moodledemo.net/admin/tool/mobile/launch.php?service=moodle_mobile_app&passport=1&urlscheme=moodlemobile'
resp = httpx.get(url, headers=headers, cookies=s.cookies)
print(resp.headers)
In case you can't try to recreate the error, it's because moodle sandbox resets every hour
So when you want to try it
Moodle Setting
(username: admin; password: sandbox)
Come to this page and change Type of login into this
from requests.
Related Issues (20)
- requests 2.32.3 with IPv6 link local address fails with error: [Errno -2] Name or service not known HOT 1
- 2.32.3 does not load system CA certificates when using an Adapter HOT 3
- GET请求,我希望传递% 但是requests会默认帮我编码为%25,如何解决? HOT 1
- requests.utils. atomic_open does not respect umask HOT 1
- Feature Request: `safe_json()` Method for Requests Library HOT 1
- auth headers lost when requests process redirected requests HOT 1
- inconsistent handling of verify and REQUESTS_CA_BUNDLE HOT 1
- requests library seems to ignore "Transfer-Encoding" header HOT 1
- ValueError: Timeout value connect was <object object at 0x7c6b5e484a80>, but it must be an int, float or None. HOT 1
- Requests v2.32.0 caused the error `Segmentation fault` when including the `cert` parameter HOT 1
- Check for codes HOT 1
- Unclear file handling in documentation examples HOT 2
- catch FileNotFoundError if there aren't any certificates HOT 1
- requests > 2.31.0 - Unhashable type 'list' for 'cert' parameter HOT 1
- RFC9113 - HTTP/2.0 HOT 1
- Possible .get bug in version 2.32.3 HOT 2
- PDF download is distorted using requests HOT 1
- Frequently hangs or times out when trying to fetch https://openssl.org/source/ HOT 3
- I am having error on requests.post HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from requests.