Search code examples
pythonbeautifulsoupget

Can't get a GET Request in Python and Postman from a website


Have been trying to scrape this website: "https://www.loopnet.com/search/commercial-real-estate/usa/for-lease/", but it keeps trying to do a get request forever even on Postman, I'm kinda lost I this is happening whatsoever.

import requests
from bs4 import BeautifulSoup

url = "https://www.loopnet.com/search/commercial-real-estate/usa/for-lease/"
headers = {
    'authority': 'www.loopnet.com',
    'pragma': 'no-cache',
    'cache-control': 'no-cache',
    'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
    'sec-ch-ua-mobile': '?0',
    'upgrade-insecure-requests': '1',
    'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36',
    'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
    'sec-fetch-site': 'none',
    'sec-fetch-mode': 'navigate',
    'sec-fetch-user': '?1',
    'sec-fetch-dest': 'document',
    'accept-language': 'en-US,en;q=0.9',
}

response = requests.get(url, headers=headers)

Solution

  • Looks like scraping is against the Terms of Use for LoopNet. They're likely blocking your requests.

    LoopNet TOS