Ge0rg3 / requests-ip-rotator

A Python library to utilize AWS API Gateway's large IP pool as a proxy to generate pseudo-infinite IPs for web scraping and brute forcing.
https://pypi.org/project/requests-ip-rotator/
GNU General Public License v3.0
1.33k stars 138 forks source link

Unable to add parameters to request #26

Closed tillea closed 2 years ago

tillea commented 2 years ago

Hi, I want to download URLs with certain parameters. For instance when trying to download

https://webtv.feratel.com/webtv/?cam=3175&t=12&design=v4

I can do with plan request

params = dict()
params['cam']="3175
params['t']="12"
params['design']="v4"
response = requests.get('https://webtv.feratel.com/webtv/', params=params)

It does not work when simply specifying the full URL and leaving out params.

Unfortunately for the get method of the session in requests-ip-rotator there is no params parameter and I guess this is the reason why trying to fetch the link above fails.

Kind regards Andreas.

abdou4a commented 2 years ago

try to use urllib.parse.urlencode

import urllib.parse
params = urllib.parse.urlencode(params)
url = "https://webtv.feratel.com/webtv/?%s" % params
tillea commented 2 years ago

Am Sun, Feb 06, 2022 at 04:11:08AM -0800 schrieb abdou4a:

try to use urllib.parse.urlencode

import urllib.parse
params = urllib.parse.urlencode(params)
url = "https://webtv.feratel.com/webtv/?%s" % params

Thanks for the hint. I tried this but the resulting string does not look different from what I tried and so the website keeps on returning 404.

Kind regards, Andreas.

Ge0rg3 commented 2 years ago

Hi, I have retested this on the latest version and believe it's fixed, as the params parameter can now be used 😄 My test code was as follows:

import requests
from rrequests_ip_rotator import ApiGateway

webhook_id = "808569d8-4aa4-4c3f-9281-289ff6628c6b"

gateway = ApiGateway("https://webhook.site", regions=["eu-west-2"])
gateway.shutdown()
gateway.start()

s = requests.Session()
s.mount("https://webhook.site", gateway)

url = f"https://webhook.site/{webhook_id}/?cam=3175&t=12&design=v4"
resp = s.get(url)
print(resp.text)

url = f"https://webhook.site/{webhook_id}/"
params = {
    "cam": 3175,
    "t": 12,
    "design": "v4"
}
s.get(url, params=params)