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 a dynamic span hefaz 0 226 Mar-07-2020, 02:56 PM
Last Post: hefaz
  scrap by defining 3 functions zarize 0 192 Feb-18-2020, 03:55 PM
Last Post: zarize
  Skipping anti-scrap zarize 0 243 Jan-17-2020, 11:51 AM
Last Post: zarize
  page impossible to scrap? :O zarize 2 545 Oct-03-2019, 02:44 PM
Last Post: zarize
  scrap macrotrends mr_byte31 7 1,419 Aug-02-2019, 12:02 AM
Last Post: mr_byte31
  Scrap arbitrage odds -help Gochix2020 3 537 Jul-31-2019, 10:45 AM
Last Post: Gochix2020
  i am trying to web scrap this .asp nufan0000 1 430 May-30-2019, 02:27 AM
Last Post: Larz60+
  Scrap Yahoo Finance using BS4 mr_byte31 7 2,246 Aug-24-2018, 02:50 PM
Last Post: Larz60+
  [Hlep]Scrap webiste mr_byte31 2 884 Jul-21-2018, 08:11 PM
Last Post: Larz60+
  beatifulsoup scrap td tag. piuk3man 1 1,126 Jun-11-2018, 06:16 AM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)