Что делать, если в ответ на get запрос приходят другие данные?
хотел парсить данные с этого сайта.
Вот теги, которые хотел получить:
Но при их поиске c помощью find_all я получаю совершенно не то:
<a class="Text-sc-179eaht-0 ExternalLink__StyledLink-atwofs-0 cwCqRS cmPwOq Legal__StyledExternalLink-sc-1ino7vo-0 ePVrBz" color="inherit" href="https://policies.google.com/privacy" rel="noopener noreferrer" target="_blank" type="text">Privacy Policy</a>,
<a class="Text-sc-179eaht-0 ExternalLink__StyledLink-atwofs-0 cwCqRS cmPwOq Legal__StyledExternalLink-sc-1ino7vo-0 ePVrBz" color="inherit" href="https://policies.google.com/terms" rel="noopener noreferrer" target="_blank" type="text">Terms of Service</a>,
<a class="LinkList__StyledLink-sc-177royv-2 efDGdZ" href="https://status.nbatopshot.com" rel="noopener noreferrer" target="_blank">Status</a>,
<a class="LinkList__StyledLink-sc-177royv-2 efDGdZ" href="https://support.nbatopshot.com/hc/en-us" rel="noopener noreferrer" target="_blank">Help</a>,
<a class="LinkList__StyledLink-sc-177royv-2 efDGdZ" href="/press">Press</a>,
<a class="LinkList__StyledLink-sc-177royv-2 efDGdZ" href="https://blog.nbatopshot.com/" rel="noopener noreferrer" target="_blank">Blog</a>, <a class="LinkList__StyledLink-sc-177royv-2 efDGdZ">Newsletter</a>,
<a class="LinkList__StyledLink-sc-177royv-2 efDGdZ" href="https://discord.com/invite/nbatopshot" rel="noopener noreferrer" target="_blank">Discord</a>,
<a class="LinkList__StyledLink-sc-177royv-2 efDGdZ" href="https://twitter.com/nbatopshot" rel="noopener noreferrer" target="_blank">Twitter</a>, <a class="LinkList__StyledLink-sc-177royv-2 efDGdZ" href="https://www.instagram.com/nbatopshot" rel="noopener noreferrer" target="_blank">Instagram</a>,
<a class="LinkList__StyledLink-sc-177royv-2 efDGdZ" href="/terms">Terms</a>,
<a class="LinkList__StyledLink-sc-177royv-2 efDGdZ" href="/privacy">Privacy</a>,
<a href="https://nba.com" rel="noopener noreferrer" target="_blank"><img alt="NBA" class="Footer__StyledNBALogo-sc-12jxkdl-9 kdZJAC" src="/static/img/NBA_logo.svg"/></a>,
<a href="https://nbpa.com/" rel="noopener noreferrer" target="_blank"><img alt="NBPA" src="/static/img/NBPA_logo.svg"/></a>]
Вот мой скрипт:
import requests
from bs4 import BeautifulSoup
def get_html(url: str, headers: dict) -> bytes:
response = requests.get(url, headers=headers)
return response.content
def get_all_links(html: bytes) -> list:
soup = BeautifulSoup(html, 'html.parser')
teg_a = soup.find_all('a')
print(teg_a)
links = []
return links
def run() -> None:
api = 'https://www.nbatopshot.com'
url = f'{api}/search'
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
'AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/89.0.4389.82 Safari/537.36'
}
html = get_html(url=url, headers=headers)
all_links = get_all_links(html=html)
print(all_links)
if __name__ == '__main__':
run()
