juancarlospaco / faster-than-requests

Faster requests on Python 3
https://gist.github.com/juancarlospaco/37da34ed13a609663f55f4466c4dbc3e
MIT License
1.11k stars 90 forks source link

status code? #160

Closed wristbleed closed 3 years ago

wristbleed commented 3 years ago

im trying to get the status code of the site but it keeps saying this

AttributeError: 'list' object has no attribute 'status_code'

code

if r.status_code == 200: return True

juancarlospaco commented 3 years ago

It returns a simple list type, you can print(response) and see it, it is [body, contentType, status_code, version, url, contentLength, headers] you can use to_dict to get Dict, you can use to_json to get a JSON.

wristbleed commented 3 years ago

alright thank you also i tried doing post on something and it kept saying

TypeError: post() missing 1 required positional argument: body

Here my code

def test(): while True: member = open('members.txt') requests.post(f'https://discord.com/api/v8/guilds/$%7BguildID%7D/bans/$%7Bid%7D?', http_headers=http_headers,threads=True) member.close

Also i was wondering if it has proxy support if so how can i use it?

juancarlospaco commented 3 years ago

Add body = ""

wristbleed commented 3 years ago

to where do i add that?

juancarlospaco commented 3 years ago

This is the full signature of post, there you can see the types and arguments:

post(
  url: string,
  body: string,
  user_agent: string,
  max_redirects: int,
  proxy_url: string,
  proxy_auth: string,
  timeout: int,
  http_headers = [("dnt", "1")],
)
juancarlospaco commented 3 years ago

Add body = "" to post( ) arguments.

wristbleed commented 3 years ago

Im really confused about what u mean by that if u mean like this

r=requests.post(body = "",f"https://discord.com/api/v{randint(6,8)}/guilds/{guild_id}/bans/{member_id}", http_headers=http_headers) it gives me a 'SyntaxError: positional argument follows keyword argument'

juancarlospaco commented 3 years ago

r = requests.post(url = f"https://discord.com/api/v{randint(6,8)}/guilds/{guild_id}/bans/{member_id}", body = "", http_headers=http_headers)

Thats just how Python function arguments work. :shrug:

wristbleed commented 3 years ago

i was just confused about how u said it but thank u also can u give me an example of how to use proxies on faster than requests because on requests i use proxies={"http": 'http://' + next(rotating)}).result() and it works fine but if i use that on faster than requests it gives me some key errors

juancarlospaco commented 3 years ago

proxy_url = "http://proxy.url.here:8080"

wristbleed commented 3 years ago

Okay thank you sm if i have another question to ask ill let u know thanks for helping me :D

wristbleed commented 3 years ago

everything works except response it just keeps saying this

    if  r.response == 200:
        return True
    else:
        return False

AttributeError: 'list' object has no attribute 'response' i tried just printing the response it didnt work either

juancarlospaco commented 3 years ago

r is a list, theres no r.response, try print( r[2] ).

wristbleed commented 3 years ago

it works thank you, for status 429, 201, 404 do i just do r[29] [21] [49] [44] or what

juancarlospaco commented 3 years ago

r is just a list, r[2] is just list indexing, item at index 2 of list r.