我该如何自动扩展整个网页以用pandas(Python)刮擦?
我正在尝试从 https://coinmarketcap.com/exchanges/exchanges/binance/binance/ )。在页面上,有一个“负载更多”按钮。单击此点时,将显示更多的行,但URL不会更改。当我使用pd.read_html(url(
>)将此URL传递给PANDAS时,它会拉出前100行,而无需其他。如何通过url或命令自动加载所有表?任何帮助都将受到赞赏。 代码:
import json
import requests
import pandas as pd
from bs4 import BeautifulSoup
import lxml
import html5lib
url = "https://coinmarketcap.com/exchanges/binance/"
df = pd.read_html(url)
pd.set_option("display.max_rows", None, "display.max_columns", None)
print(df)
I am trying to scrape html tables from https://coinmarketcap.com/exchanges/binance/ . On the page, there is a "load more" button. When this is clicked, more rows are displayed, but the URL doesn't change. When I pass this URL to pandas using pd.read_html(url(
, it pulls the first 100 rows and nothing else. How do I auto load all the tables, either through the URL or through a command? Any help is appreciated.
Code:
import json
import requests
import pandas as pd
from bs4 import BeautifulSoup
import lxml
import html5lib
url = "https://coinmarketcap.com/exchanges/binance/"
df = pd.read_html(url)
pd.set_option("display.max_rows", None, "display.max_columns", None)
print(df)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,由于所有结果已加载,URL不会更改,默认情况下没有显示它们以节省加载时间。
您很可能需要创建一个脚本,该脚本会在出现时继续单击“更多负载”,然后运行刮板。
Yes the URL does not change as all the results are loaded, they are just not displayed by default to save load time probably.
You most likely need to create a script which will keep clicking 'load more' whenever it appears and then run your scraper.