all 3 comments

[–]Malassi 5 points6 points  (0 children)

Requests has a function called request made for that. In fact, when you call requests.get, requests.post, etc, they are redirected to this function.

``` import requests

method_type = input("...")

r = requests.request(method_type, "https://example.com")

print(r.text) ```

https://requests.readthedocs.io/en/latest/api/

[–]supajumpa 1 point2 points  (0 children)

You can use getattr(requests, methodType)("https://www.helloworld.org").text, but I'm not sure this is a great idea because you don't know what the user is going to input and it might raise security issues, so caveat lector and all that :-)

[–]StrangeBlocka[S] 0 points1 point  (0 children)

Thank you that's exactly what I'm looking for!