Home php教程 php手册 用QueryList采集金山词霸《每日一句》

用QueryList采集金山词霸《每日一句》

Jun 06, 2016 pm 07:37 PM
querylist one sentence a day collection Jinshan

采集金山词霸的每日一句,需要说明的是,并不能直接匹配出音频的地址,匹配出来的是类似于这样个字符串: iciba_common_top_onSecondDelay(http://news.iciba.com/admin/tts/2015-02-27.mp3); 所以需要用个回调函数来过滤出音频地址。 phpQuery ?phprequire '

采集金山词霸的每日一句,需要说明的是,并不能直接匹配出音频的地址,匹配出来的是类似于这样个字符串:
iciba_common_top_onSecondDelay('http://news.iciba.com/admin/tts/2015-02-27.mp3');
所以需要用个回调函数来过滤出音频地址。 phpQuery
<?php
require '../QueryList/QueryList.class.php';

$url = 'http://news.iciba.com/dailysentence';
$reg = ".pic";
$rang = array(
        //匹配英文
        "en" => array(".en>a","text"),
        //匹配中文
        "cn" => array(".cn>a","text"),
        //匹配音频
        "audio" => array(".sound","onmouseover",'',function($v,$k){
                                //回调函数,用于匹配出音频地址
                                if(preg_match('/http[^\']+/',$v,$arr))
                                {
                                    $v = $arr[0];
                                }
                                return $v;
                         }),
        //匹配图片
        "pic" => array("a:eq(0)>img","src"),
        //匹配页面地址
        "page" => array("a:eq(0)","href")
    );
$data = QueryList::Query($url,$rang,$reg)->jsonArr[0];
print_r($data);
Copy after login
Array
(
[en] => Courage is not the absence of fear, but rather the judgement that something else is more important than fear.
[cn] => 勇者并非无所畏惧,而是判断出还有比恐惧更值得重视的东西。
[audio] => http://news.iciba.com/admin/tts/2015-02-27.mp3
[pic] => http://cdn.iciba.com/news/word/big_2015-02-27b.jpg?rand=8637
[page] => http://news.iciba.com/dailysentence/detail-1212.html
)
Copy after login
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)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months 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)

iCloud storage full notification: How to fix it iCloud storage full notification: How to fix it Apr 24, 2024 pm 04:43 PM

Does your iPhone show "iCloud Storage Full" whenever you download some files or airdrop something? The free plan of iCloud storage is limited to only 5GB. Therefore, the first thing you should check is the current iCloud storage situation on your phone. If there is still enough storage space and you receive a notification, these solutions will help you troubleshoot. Fix 1 – Delete iCloud Backup Remove the existing version of iCloud backup from your phone settings. Step 1 – Open Settings. Step 2 – You will find your Apple ID at the top of the Settings panel. Click on it to open it. Step 3 – Turn on “iCloud” to open iCloud settings. Step 4 – Down

Kingsoft Office WPS 365 announces its new release on April 9: 'One-stop AI Office” Kingsoft Office WPS 365 announces its new release on April 9: 'One-stop AI Office” Apr 07, 2024 pm 01:31 PM

The official announcement of the Kingsoft Office Productivity Conference will be held at 15:00 on April 9, announcing that "WPS365 is newly released." The official poster reads "One-stop AI office productivity will take off immediately", implying that WPS365 will usher in more AI function upgrades. In April 2023, Kingsoft Office launched the digital office brand WPS365 for government and enterprise customers. This service provides a series of content creation applications and office collaboration tools, covering four major sections: content creation, communication creation, digital asset management, and open ecology, including WPSOffice, document center, Kingsoft collaboration, Kingsoft meeting, email, calendar and other general office suites. Checking the WPS365 official website, we learned that the trial version of the service is free to use, and the commercial version is priced from 199 yuan/person/year, and requires a minimum purchase of 5 people.

How to use Go language for real-time data collection? How to use Go language for real-time data collection? Jun 10, 2023 pm 05:46 PM

With the continuous development of Internet of Things technology, real-time data collection has become an indispensable part of the digital era. Among various programming languages, Go language has become an ideal choice for real-time data collection with its efficient concurrency performance and concise syntax. This article will introduce how to use Go language for real-time data collection. 1. Selection of data collection framework Before using Go language for real-time data collection, we need to choose a data collection framework that suits us. The more popular data collection frameworks currently on the market include

iPhone stuck in Do Not Disturb mode: How to fix it iPhone stuck in Do Not Disturb mode: How to fix it May 03, 2024 pm 09:07 PM

Is your iPhone stuck in Do Not Disturb mode? It can be troublesome if you can't toggle Do Not Disturb mode. You won't receive any alerts at all. It won't take much effort to fix this DND issue on iPhone. So, no need to waste any more time and just follow these simple solutions to solve your problem. Fix 1 – Remove the Do Not Disturb schedule If you have any Do Not Disturb schedule on your phone, it may force the device to automatically go into Do Not Disturb mode. Step 1 – Go to your iPhone’s Settings. Step 2 – Next, turn on Focus mode. Step 3 – You will find “Do Not Disturb” at the top of the chart. Step 4 – Open it. Step 5 – On the next page, if you go to the Schedule tab, you

iPhone screen keeps returning to home screen iPhone screen keeps returning to home screen Apr 17, 2024 am 08:28 AM

Does your iPhone screen keep returning to the home screen every time you open a specific app? This is an unusual behavior and the reason you are returned to the home screen is that the app crashed for some reason. Troubleshooting will be easier if you follow these set of instructions. Fix 1 – Change Tap Behavior One of the back gestures on iPhone lets you minimize the current app. Disabling the click behavior should resolve this issue. Step 1 – Open Settings. Step 2 – Later, visit Accessibility settings to turn it on. Step 3 – Go to the “Physics & Motors” feature and open the “Touch” settings. Step 4 – Swipe all the way down to the “BackTap” settings. Open it. Step 5 – On the Back Click page, select

Unable to check for updates error in iPhone: Fix Unable to check for updates error in iPhone: Fix Apr 17, 2024 pm 10:40 PM

Are you getting this error message "Unable to check for updates" message while checking for updates on your iPhone? Usually, this message appears when you manually search for updates while your phone is offline. Therefore, we recommend you to enable Wi-Fi/Cellular data and perform the same operation again. If you're still experiencing the issue, follow the remaining troubleshooting tips. Fix 1 – Enable Wi-Fi/Cellular Data Enable Wi-Fi or Cellular data and try checking for updates again. Step 1 – Simply swipe down to access the Control Center. Step 2 – Enable Wi-Fi or Cellular on your phone. Now try the update process again after enabling network connectivity. Fix 2 – Force restart iPhone if Wi-Fi/Bee is enabled despite

How to connect Baidu Wenxin Yiyan API with PHP to obtain daily sentences and send them to the user's mailbox How to connect Baidu Wenxin Yiyan API with PHP to obtain daily sentences and send them to the user's mailbox Aug 12, 2023 am 09:00 AM

How to connect Baidu Wenxin Yiyan API with PHP to obtain a daily sentence and send it to the user's mailbox. With the rapid development of the Internet and mobile Internet, users' demand for personalized services is also getting higher and higher. As a website developer, if you can provide users with unique and exciting text content in one sentence every day, you will attract more user attention and participation. This article will introduce how to use PHP to connect to Baidu Wenxin Yiyan API to obtain a daily sentence and send it to the user's mailbox. First, we need to register a Baidu developer account and apply

Using QueryList in ThinkPHP6 Using QueryList in ThinkPHP6 Jun 20, 2023 am 09:15 AM

With the continuous development of Internet technology, data crawlers have become one of the important ways for people to obtain information. In the PHP framework, ThinkPHP6 not only provides powerful data manipulation functions, but also provides us with a data grabbing library called QueryList to help us obtain data more conveniently. QueryList is a PHP data collection and processing library based on streaming chain operations. It can extract data from various types of text such as HTML, XML, JSON, TXT, etc. This article will

See all articles