Home Backend Development PHP Tutorial 抓取YAHOO股票报价的类_PHP

抓取YAHOO股票报价的类_PHP

Jun 01, 2016 pm 12:23 PM
yahoo stock

复制代码 代码如下:

function getYahooQuote($stockSymbol = "CCR")
{
if (!$targetURL) $targetURL = "http://finance.yahoo.com/q?s=$stockSymbol&d=t"; //设定要抓取的URL目标
$fd = fopen("$targetURL", "r");
$stopExtract = 0;
$startExtract = 0;
while (!feof($fd))
{
$buffer = fgets($fd, 4096);
//echo trim($buffer)."\n";
if (strstr($buffer, "rowspan=3"))
{
//echo "extract started at line #$lineCount\n";
$startExtract = 1;
}
if ($startExtract && !$stopExtract)
{
if (strstr($buffer, "{
$startPos = strrpos($buffer, "$buffer = substr($buffer, $startPos);
}
//$text = trim(strip_tags($buffer));
//echo trim($buffer)."\n";
$buffer = str_replace("\n\r", " ", "$buffer");
if (strstr($buffer, "http://ichart.yahoo.com/v?s=$stockSymbol"))
{
//echo "ichart found!";
$stopExtract = 1;
}
$capturedHTML .= $buffer;
}
if ($startExtract && strstr($buffer, "
"))
{
$stopExtract = 1;
//echo "extract stopped at line #$lineCount\n";
echo $capturedHTML;
break;
}
$lineCount ;
}
fclose($fd);
}
//以下为抓取的一个例子
$symbols = array('CCR', 'IIXL','SAPE','WBVN' );
$symbolCount = count($symbols);
for ($i=0; $i{
echo "$symbols[$i]
";
getYahooQuote("$symbols[$i]");
}
?>

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the best way to get stock data using Python? What is the best way to get stock data using Python? Aug 26, 2023 pm 01:41 PM

In this article, we will learn the best way to get stock data using Python. The yfinancePython library will be used to retrieve current and historical stock market price data from Yahoo Finance. Install Yahoo Finance (yfinance) One of the best platforms to get stock market data is Yahoo Finance. Simply download the dataset from the Yahoo Finance website and use the yfinance library and Python programming to access it. You can install yfinance with the help of pip, all you have to do is open the command prompt and type the following command to show the syntax: Syntax pipinstallyfinance The best part about the yfinance library is that it is free to use and does not require an API key like

What is yahoo? What is yahoo? Dec 07, 2020 pm 05:17 PM

Yahoo is Yahoo, a well-known Internet portal in the United States. Its services include search engines, emails, news, etc. Its business covers 24 countries and regions, providing diversified network services to more than 500 million independent users around the world; it is also a global Internet communications, commerce and media company. Yahoo has 12 language versions including English, Chinese, Japanese, Korean, French, German, Italian, Spanish, and Danish. The content of each version is different from each other; it provides directory, website and full-text search functions.

Practical crawler practice: using PHP to crawl stock information Practical crawler practice: using PHP to crawl stock information Jun 13, 2023 pm 05:32 PM

The stock market has always been a topic of great concern. The daily rise, fall and changes in stocks directly affect investors' decisions. If you want to understand the latest developments in the stock market, you need to obtain and analyze stock information in a timely manner. The traditional method is to manually open major financial websites to view stock data one by one. This method is obviously too cumbersome and inefficient. At this time, crawlers have become a very efficient and automated solution. Next, we will demonstrate how to use PHP to write a simple stock crawler program to obtain stock data. allow

AI Tom Cat has been registered, what points should investors pay attention to in Tom Cat stock? - 123 Finance AI Tom Cat has been registered, what points should investors pay attention to in Tom Cat stock? - 123 Finance Sep 15, 2023 pm 08:41 PM

As an all-in-one IP ecological operator, Tomcat has recently made important progress in the field of artificial intelligence. The AI ​​​​Tom Cat product cooperated with Xihu Xinchen has passed the registration and officially started closed testing on August 27. This product has multiple functions such as photo recognition, English speaking enlightenment, interest guidance, popular science education, AI generated pictures, AI generated picture books, situational dialogue, etc. 123 Finance believes that this move will further expand Tom Cat’s IP ecosystem and provide users with a more intelligent and interactive experience. The Xihu Xinchen team that cooperates with Tom Cat is a top domestic AI technology team with more than 60 people. The team has extensive experience in the field of artificial intelligence and has successfully developed "ALBERT", a lightweight version of Google's large model BERT. he

Revealing stock investment opportunities at Microsoft's Win11 launch event Revealing stock investment opportunities at Microsoft's Win11 launch event Dec 26, 2023 pm 06:32 PM

Microsoft previously officially released the new win11 system at a press conference, which caused its stock price to rise significantly. Therefore, many domestic investors want to take advantage of this craze to see which other stocks will benefit. Let’s take a look with the editor. Which stocks will benefit from Microsoft’s win11 conference: 1. Microsoft. 1. Microsoft’s win11 conference will naturally benefit its own stock. 2. According to relevant performance, Microsoft’s stock price rose to US$259.89 after the press conference, an increase of 0.78%. 3. In addition, according to the forecast maintained by Mike Peak, the target price of Microsoft's stock price is US$301, so there is still a lot of room for growth. 2. Huiguan Co., Ltd. 1. Huiguan Co., Ltd. is one of the touch screen suppliers of Lenovo Computer and has obtained the Microsoft Lo

Zuckerberg cashes out nearly $200 million, sells 560,000 Meta shares Zuckerberg cashes out nearly $200 million, sells 560,000 Meta shares Dec 04, 2023 pm 09:42 PM

According to documents released by the U.S. Securities and Exchange Commission (SEC), this site learned that Mark Zuckerberg sold Meta stock almost every day in December. As of November 29, he had sold a total of 560,180 shares. A form filed with the SEC on November 30 showed that he planned to sell an additional 28,009 shares of Meta stock. Based on the closing price of the day ($327.15), the total value of these stocks is approximately $192.90 million (note on this site: currently approximately 1.377 billion yuan). It is worth mentioning that the MetaPlatforms shares sold this time are indirectly owned by Zuckerberg through various funds. The entire disclosure of sales and other processes also complies with the 10b5-1 trading rules set by the SEC.

98% of South Korean stocks fell: Samsung Electronics fell more than 10%, the largest decline since 2008 98% of South Korean stocks fell: Samsung Electronics fell more than 10%, the largest decline since 2008 Aug 07, 2024 pm 05:29 PM

According to news from this site on August 5, Yonhap News Agency reported that due to the adverse impact of the deterioration of U.S. economic indicators, the Korea Composite Stock Price Index (KOSPI, calculated by the prices of all stocks traded on Korean exchanges) fell below 2,500 points on the 5th. . Among the stocks listed on KOSPI, 98% fell. As of the publication of this article, the Korea Composite Stock Price Index (KOSPI) was 2441.33, a decrease of 8.78%. Samsung Electronics' stock price fell by more than 10%, its largest decline since 2008. Previously, its largest union, NSEU, called on members to return to work, but said the strike would continue for a long time. In addition, all the top 200 stocks by market capitalization showed a downward trend. SK Hynix (-9.53%), Hyundai Motor (-8.40%), Kia (

The difference between virtual currency and stocks_What are the differences between virtual currency trading and stock trading The difference between virtual currency and stocks_What are the differences between virtual currency trading and stock trading Feb 15, 2025 pm 12:21 PM

Virtual currencies and stocks are two completely different investment categories. Stocks represent ownership of listed companies, while virtual currencies are decentralized and unregulated digital assets. It is crucial to understand the key differences between virtual currency trading and stock trading in order to make informed investment decisions.

See all articles