Home > OS >  Python requests - getting 503 response
Python requests - getting 503 response

Time:09-12

When I'm trying to scrape 1337x.to I get response 503 (service unavailable).

This is my code:

headers = {
                        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0',
                        'Accept': 'text/html,application/xhtml xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
                        'Accept-Language': 'en-US,en;q=0.5',
                        # 'Accept-Encoding': 'gzip, deflate, br',
                        'Connection': 'keep-alive',
                        # 'Cookie': '__cf_bm=8AWn5cgl3wrLk8I2mbjcWF2hZo6yTMkQVbABnjiu06A-1662900329-0-AbK6GqFf8nWKuLYRCwJ5Ihk6 gS1Q9KumHHO7SoJPYtnpuFG1l4gJHnYw/L r lApFRAVgw7JOQNIfhdfo64/GN1 O7RrjVep7rS0515TiUA1kNuExIIavYFcsgHBwQcqQ==',
                        'Upgrade-Insecure-Requests': '1',
                        'Sec-Fetch-Dest': 'document',
                        'Sec-Fetch-Mode': 'navigate',
                        'Sec-Fetch-Site': 'none',
                        'Sec-Fetch-User': '?1',
                    }

response = requests.get('https://1337x.to/popular-movies', headers=headers)

I tried without headers as well, but got the same result.

Any help will be appreciated!

CodePudding user response:

>>> import requests
>>> response = requests.get('https://1337x.to/popular-movies')
>>> response
<Response [200]>

I get the above result. The only reason I see is you probably made too many requests(or their website was actually down). As a rule of thumb always have some cooling period between subsequent requests when scraping a website.

  1. That is the responsible thing to do so you don't disturb the performance of the given website.
  2. Your IP won't be blocked if any such WAF rule is present on the website's server.
  • Related