0
from bs4 import BeautifulSoup
import requests

web_url = r'https://www.mlb.com/scores/2019-05-12'
get_web = requests.get(web_url).text
soup = BeautifulSoup(get_web,"html.parser")
score = soup.find_all('div',class_='container')
print(score)

I want to find this.

But result is this

Partho63
  • 3,117
  • 2
  • 21
  • 39

1 Answers1

0

Send headers to API to tell it "hey I'm a desktop browser" to get identical HTML from server side:

user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'
request = requests.get(url, headers={'User-Agent': user_agent})

Useful links:

  1. How to use Python requests to fake a browser visit?
  2. Sending "User-agent" using Requests library in Python
knh190
  • 2,744
  • 1
  • 16
  • 30