一直在尝试抓取这个网站:“https://www.loopnet.com/search/commercial-real-estate/usa/for-lease/”,但它一直在尝试永远执行获取请求,即使在邮递员,无论如何,我有点迷失了。
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)
看起来抓取违反了 LoopNet 使用条款。他们可能会阻止您的请求。