Write the Code. Change the World.

7月 09

Text(
    '给我一个理由忘记',
    overflow: TextOverflow.ellipsis,
    maxLines: 2,
    style: TextStyle(
        fontSize: 13.0
    ),
)

在某些场景下无法换行,请用 Expanded

Expanded (
    child: Text(
        '给我一个理由忘记',
        overflow: TextOverflow.ellipsis,
        maxLines: 2,
        style: TextStyle(
            fontSize: 13.0
        ),
    )
)

也可以套 Container ,设置宽度来限制文本的宽度。

7月 09

准备

https://github.com/FriendsOfPHP/Goutte

https://github.com/guzzle/guzzle

https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html

安装

composer require fabpot/goutte

composer require guzzlehttp/guzzle

试试

先看看 goutte

use Goutte\Client;

$client = new Client();
$crawler = $client->request('GET', 'https://www.yuepaibao.com/moments');
$crawler->filter('.content span')->each(function ($node) {
print $node->text()."\n";
});

**再看看 GuzzleHttp **

use GuzzleHttp\Client as GoutteClient;
use GuzzleHttp\Psr7\Request as GuzzleRequest;

$url = 'https://www.hao123.com';
$request = new GuzzleRequest('GET', $url);
$client = new GoutteClient();
$response = $client->send($request, ['timeout' => 5]);
$content = $response->getBody()->getContents();
echo $content;

特殊

https://learnku.com/laravel/t/3590/php-crawls-the-page-that-needs-to-run-js-run-js-grabing-web-page-with-php-while