-10

I have been trying to scrap the table under the tab "Price History" from the website http://merolagani.com/CompanyDetail.aspx?symbol=ADBL

I have used Selenium to automate the process but cant actually find the actual result and cannot change to next page

Rahul
  • 18,271
  • 7
  • 41
  • 60
  • 1
    Your code trial please. – undetected Selenium Dec 18 '17 at 16:50
  • 3
    always put code and full error message (Traceback) in question (as text, not screenshot). There are useful informations. – furas Dec 18 '17 at 16:56
  • JavaScript/AJAX reads data from `http://merolagani.com/handlers/webrequesthandler.ashx?type=get_company_graph&symbol=ADBL&dateRange=12` – furas Dec 18 '17 at 20:23
  • have added the ruby code which actually does some work in answer section and having real problem with python as i cannot use the Selenium to automate the process of clicking the next button. – Binod Aryal Dec 19 '17 at 08:06
  • 1
    Possible duplicate of [selenium with scrapy for dynamic page](https://stackoverflow.com/questions/17975471/selenium-with-scrapy-for-dynamic-page) – parik Dec 19 '17 at 10:26
  • here in this page https://www.ebay.com/sch/i.html?_odkw=books&_osacat=0&_trksid=p2045573.m570.l1313.TR0.TRC0.Xpython&_nkw=python&_sacat=0&_from=R40 URL will be changed as we click next [pgn=2] in url. in http://merolagani.com/CompanyDetail.aspx?symbol=ADBL page there is "Price History" tab which will show the pagination table but as page is build with ajax there will be no change in URL as we click "Price History" tab or next bottom of pagination table – Binod Aryal Dec 19 '17 at 14:57

1 Answers1

0

EDIT: after few more test I see this url gives only data used by plot/graph on page, not data from "Price History". I don't see url with "Price History" data so this answer doesn't resolve problem. It will need more digging in requests and code.

Page is created with ASP.Net which has very wierd system to send infromation to server.
Instead of links it uses JavaScript with <form> to send many information (in fields with name like _VIEWSTATE).


JavaScript read data (as JSON) from urls like

http://merolagani.com/handlers/webrequesthandler.ashx?type=g‌​et_company_graph&sym‌​bol=ADBL&dateRange=1‌​2

so you can try do read it too

import requests

url = 'http://merolagani.com/handlers/webrequesthandler.ashx?type=get_company_graph&symbol=ADBL&dateRange=12'

r = r.requests(url)

data = r.json()

print('OK:', data['msgType'])
print('Symbol:', data['symbol'])
print('Name:', data['name'])
for row in data['quotes']:
    print('  date:', row['date'])
    print('  open:', row['open'])
    print(' close:', row['close'])
    print('  high:', row['high'])
    print('   low:', row['low'])
    print('volume:', row['volumen'])
    print('   rsi:', row['rsi'])
    print('----------------------')

Result:

OK: ok
Symbol: ADBL
Name: Agriculture Development Bank Limited
  date: 12/18/2016
  open: 540.0
 close: 540.0
  high: 540.0
   low: 525.0
volume: 6847.0
   rsi: 0.0
----------------------
  date: 12/19/2016
  open: 535.0
 close: 520.0
  high: 535.0
   low: 520.0
volume: 6963.0
   rsi: 0.0
----------------------
  date: 12/20/2016
  open: 520.0
 close: 520.0
  high: 530.0
   low: 505.0
volume: 9974.0
   rsi: 0.0
----------------------
furas
  • 134,197
  • 12
  • 106
  • 148