Search code examples
pythonpandasdatareader

Read html where required table needs user's input


I want to read the table from 'https://coinmarketcap.com/exchanges/bitfinex/', however I need 'pair' to be set to 'USD'. By default it is set to 'All'. Changing 'USD' to 'All' doesnt change the url or anything so when I give the link to pandas_datareader it finds only default table.

Is there any way I can read the needed table?


Solution

  • It seems this page has all data in HTML and it uses JavaScript to filter data in table when you select USD. So it doesn't use other URL to get data and it doesn't use AJAX to load them from other URL - so you can't get it by changing URL

    You can only get all data and later filter rows

    import pandas as pd
    
    all_dfs = pd.read_html('https://coinmarketcap.com/exchanges/bitfinex/')
    
    df = all_dfs[2]
    
    df[ df['Pair'].str.endswith('USD') ]