网站使用javascript时如何查找来源 [英] How to find a source when a website uses javascript

查看:28
本文介绍了网站使用javascript时如何查找来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Beautiful-soup 抓取下面的网站,当我加载页面时,它没有提供显示各种引号的表格.在我之前的帖子中,人们帮助我提供了实际提供主网站的网站,但我不确定他们是如何找到它的.一旦我提取了数据,我就可以做剩下的事情了.

I am trying to scrape the website below using Beautiful-soup and when I load the page it does not give the table that shows various quotes. In my previous posts folks have helped me providing the website that actually fed the main website but I am not sure how did they find it.Once I have pulled the data I can do the rest.

https://www.cmegroup.com/trading/energy/refined-products/methanol-t2-fob-rdam-icis.html

我尝试使用 Selenium 驱动程序,但遇到不同的错误,这可能需要更多时间并且使用 Selenium 不舒服.最终我打算创建一个将信息下载到 excel 文件的 exe.

I tried to use Selenium driver but getting different errors which might need more time and not comfortable using Selenium. Eventually I plan to create an exe that downloads the information to excel file.

推荐答案

Web 中的很多页面都使用 JS 来更改页面.这些变化对 Beautiful-soup 是不可见的,因为它不执行 JS.我能想到两个选择:

Lots of pages in the web uses JS to change the page. These changes are not visible to Beautiful-soup because it doesn't execute JS. I can think of two options:

  • 您可以使用像 Selenium 这样的工具,这些工具实际上可以使用 JS 运行一个成熟的浏览器.
  • 您可以在 Chrome 或 Firefox 中打开网站,打开网页检查器而不是刷新页面.在网络选项卡中观察 XHR 请求,您可能会发现带来您正在寻找的数据的请求.如果找到它,您可以直接加载该页面而不是主页.

这篇关于网站使用javascript时如何查找来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆