It's because the first ten results are in the HTML you get back. However, the rest is added dynamically by JavaScript, so BeautifulSoup won't see this because it's simply not there.
However, there's an API you can use to get the table data (for all the pages too, if you feel like it).
Here's how:
from urllib.parse import urlencode
import requests
from tabulate import tabulate
query_string = [
('start', '1'),
('limit', '100'),
('sortBy', 'market_cap'),
('sortType', 'desc'),
('convert', 'USD'),
('cryptoType', 'all'),
('tagType', 'all'),
]
base = "https://api.coinmarketcap.com/data-api/v3/cryptocurrency/listing?"
response = requests.get(f"{base}{urlencode(query_string)}").json()
results = [
[
currency["name"],
round(currency["quotes"][0]["price"], 4),
]
for currency in response["data"]["cryptoCurrencyList"]
]
print(tabulate(results, headers=["Currency", "Price"], tablefmt="pretty"))
Output:
+-----------------------+------------+
| Currency | Price |
+-----------------------+------------+
| Bitcoin | 46204.9211 |
| Ethereum | 1488.0481 |
| Tether | 0.9995 |
| Binance Coin | 212.8729 |
| Cardano | 0.93 |
| Polkadot | 31.1603 |
| XRP | 0.4464 |
| Litecoin | 167.2676 |
| Chainlink | 25.1752 |
| Bitcoin Cash | 488.9875 |
| Stellar | 0.3724 |
| USD Coin | 0.9998 |
| | |
| and many more | values |
+-----------------------+------------+
EDIT: To loop over the pages you might want to try this:
from urllib.parse import urlencode
import requests
query_string = [
('start', '1'),
('limit', '100'),
('sortBy', 'market_cap'),
('sortType', 'desc'),
('convert', 'USD'),
('cryptoType', 'all'),
('tagType', 'all'),
]
base = "https://api.coinmarketcap.com/data-api/v3/cryptocurrency/listing?"
response = requests.get(f"{base}{urlencode(query_string)}").json()
last_page = (int(response["data"]["totalCount"]) // 100) + 1
all_pages = [1 if i == 1 else (i * 100) + 1 for i in range(1, last_page)]
for page in all_pages[:2]:
query_string = [
('start', str(page)),
('limit', '100'),
('sortBy', 'market_cap'),
('sortType', 'desc'),
('convert', 'USD'),
('cryptoType', 'all'),
('tagType', 'all'),
]
response = requests.get(f"{base}{urlencode(query_string)}").json()
results = [
[
currency["name"],
round(currency["quotes"][0]["price"], 4),
]
for currency in response["data"]["cryptoCurrencyList"]
]
print(results)
NOTE: I'm throttling this example by adding [:2] to the for loop, but if you want to go for all the pages just remove this [:2] so the loop looks like this:
for page in all_pages:
# the rest of the body ...