


我在搜狐上查询了三只股票的数据,网址如下:
http://q.stock.sohu.com/cn/msq.shtml?q=cn_000022,cn_600019,cn_600028
打开网页之后,能看到一个表格,它的数据复制下来就是如下内容:
=======内容开始===========================================================
股票代码 股票名称 当前价 涨跌额 涨跌幅 总手 现手 成交金额 换手率 今低-今高 今开盘 昨收盘
000022 深赤湾A 11.70 -0.30 -2.50% 8844 86 1034 0.19% 11.60-11.80 11.60 12.00
600019 宝钢股份 5.17 -0.06 -1.15% 321813 63 16563 0.18% 5.11-5.19 5.15 5.23
600028 中国石化 7.01 -0.06 -0.85% 244512 47 17029 0.03% 6.90-7.02 6.97 7.07
=======内容结束===========================================================
如果我察看该网页的源代码,发现这一块相应的代码是:
=======代码片段开始===========================================================
股票代码 | 股票名称 | 当前价
| 涨跌额
| 涨跌幅
| 总手
| 现手
| 成交金额
| 换手率
| 今低-今高 | 今开盘 | 昨收盘 |
---|---|---|---|---|---|---|---|---|---|---|---|
=======代码片段结束===========================================================
我的问题是为什么看不到“宝钢股份”、“600019”、“中国石化”这样字样?我当初学习html的时候,不是说网页上显示的东西都能在源代码中找到么?搜狐它这个网页为什么从源代码中找不到?
另外,如果用另存为的办法将网页保存到本地,也会发现三行股票数据消失,只剩下表格头:
=======保存到本地文件后观察到的内容开始===========================================================
股票代码 股票名称 当前价 涨跌额 涨跌幅 总手 现手 成交金额 换手率 今低-今高 今开盘 昨收盘
=======保存到本地文件后观察到的内容结束===========================================================
为什么会出现这样的现象呢?
回复讨论(解决方案)
估计这些数据通过AJAX异步获取的。
我其实对如何获取那三行股票数据有兴趣,不知道搜狐这个页面用来获取数据的代码是不是藏在这个页面中?有高手请进来指导一下哦。
源代码指显示后台response过来的
JS打印的,包括AJAX的,是木有、
看这个JS文件
谢谢KongHuLu兄,这个js文件暂时看不太懂。咱们有木有什么办法通过调用这个js文件从自己的local服务器上搞一个网页来得到相同的数据?
或者说,如何用vba把这3行数据抓到excel或者access当中来啊?
学一下AJAX就明白了。保存什么的,就是保存页面的源码,不包括页面逻辑执行后的结果。
学明白AJAX就知道如何利用了,很简单。
谢谢,我学学去。
为了加快学习进度,theforever兄能否给个简单的例子?比如用excel的vba代码获取哪怕一个开盘价,剩下的我再慢慢学。
谢谢,我学学去。
为了加快学习进度,theforever兄能否给个简单的例子?比如用excel的vba代码获取哪怕一个开盘价,剩下的我再慢慢学。 你的问题解决没有能不能给点意见?
It should be displayed using js or the like, and there is no static output, so it is not in the source code, it is dynamic!
[Quote=quote 8th floor’s reply:]
Thank you, I will learn from it go.
In order to speed up the learning process, can brother theforever give a simple example? For example, I can use Excel's VBA code to get even an opening price, and I will learn the rest slowly. Can you give me some advice on how to solve your problem?
Sorry, I haven’t researched it yet.
I downloaded a book called Head First Ajax online. I don’t have time to read it yet, so I’ll post it first. Thank you.

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
