Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Scrap a value from website
#1
Iam trying scrap trade date value -- below is what i have written, but not getting the value. Can someone help on this.

#!/usr/bin/env python
import urllib2, json
ua = { 'User-Agent' : 'Mozilla/5.0' }
request = urllib2.Request('http://www.cmegroup.com/CmeWS/mvc/TimeandSales/300/G/N8?timeSlot=16&entryDate=20180522&pageNumber=1&_=1527157308610', headers=ua)
response = urllib2.urlopen(request)
data = json.loads(response.read())
response.close()
print data['tradeDate']
Quote
#2
Use Requests,and stop using Python 2.
import requests

url = 'https://www.cmegroup.com/CmeWS/mvc/TimeandSales/300/G/N8?timeSlot=16&entryDate=20180522&pageNumber=1&_=1527157308610'
response = requests.get(url).json()
Output:
>>> response {'entries': [], 'productDescription': 'Corn Futures Jul 2028 Globex', 'props': {'pageNumber': 1, 'pageSize': 100, 'pageTotal': 0}, 'tradeDate': '-'} >>> response['tradeDate'] '-'
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Scrap text out of td table from URLS Gochix2020 4 261 Aug-03-2019, 02:56 AM
Last Post: Larz60+
  scrap macrotrends mr_byte31 7 338 Aug-02-2019, 12:02 AM
Last Post: mr_byte31
  Scrap arbitrage odds -help Gochix2020 3 236 Jul-31-2019, 10:45 AM
Last Post: Gochix2020
  i am trying to web scrap this .asp nufan0000 1 230 May-30-2019, 02:27 AM
Last Post: Larz60+
  Scrap Yahoo Finance using BS4 mr_byte31 7 1,457 Aug-24-2018, 02:50 PM
Last Post: Larz60+
  [Hlep]Scrap webiste mr_byte31 2 661 Jul-21-2018, 08:11 PM
Last Post: Larz60+
  beatifulsoup scrap td tag. piuk3man 1 715 Jun-11-2018, 06:16 AM
Last Post: buran
  web scrap currency ikeen 6 1,161 Jun-04-2018, 11:59 AM
Last Post: ikeen

Forum Jump:


Users browsing this thread: 1 Guest(s)