I am trying to webscrape the following:
In particular to get Totals in that First table (block trades, EFP,EFR etc)
When I inspect the page I get different results than when I actually go to scrape and get the "page Source" data. This is making it difficult to find the data for me (im new to this)
After some exploring I found the data in https://www.cmegroup.com/CmeWS/exp/voiProductDetailsViewExport.ctl?media=json&tradeDate=20210507&reportType=F&productId=316 which is an excel file
My code so far is
header= {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) '
'AppleWebKit/537.11 (KHTML, like Gecko) '
'Chrome/23.0.1271.64 Safari/537.11',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'Accept-Encoding': 'none',
'Accept-Language': 'en-US,en;q=0.8',
'Connection': 'keep-alive'}
url = "https://www.cmegroup.com/content/cmegroup/en/trading/interest-rates/us-treasury/10-year-us-treasury-note_quotes_volume_voi.html"
r = Request(url, headers={'User-Agent': 'Mozilla/5.0'})
response = urlopen(r)
soup = BeautifulSoup(response, 'lxml')
In short does anyone have a recommendation on a better way to do this than having to sort through Excel files? Thanks!