欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

php curl 采集小說

衛若男1年前9瀏覽0評論

在網絡世界中,小說是一種十分受歡迎的文學形式。網絡上有許多小說網站,為了方便用戶瀏覽,也讓有些網站提供了小說的API,可以方便我們通過php curl來采集想要的小說內容。

小說網站提供的API可以選擇用curl來獲取數據,因為php curl不僅方便,而且可以進行高級curl功能設置,例如自定義請求頭,超時時間等。我們可以用curl的GET方法,向API發送請求,獲取API返回的JSON數據格式,并使用json_decode將JSON數據解析為php數組,然后分別提取書名、作者和小說章節內容等信息。

$apiKey = 'xxxxxxxxx';//API Key
$novelId = 'xxxxx';//小說ID
$curl = curl_init();
$headers = array(
'authorization: Basic '.$apiKey,
'content-type: application/json',
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_URL, 'http://api.xxxxxx.com/novel/'.$novelId);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$json = curl_exec($curl);
curl_close($curl);
$novelInfo = json_decode($json, TRUE);

在采集網絡小說時,我們通常想要將標題、章節和正文內容分別保存到數據庫中,以便后面查看或閱讀。我們可以使用php正則表達式來解析第二層HTML網頁,提取其中的章節標題和正文內容。下面是采集章節內容的示例代碼:

$chapterUrl = 'http://www.xxx.com/xxx.html';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $chapterUrl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($curl);
curl_close($curl);
preg_match('/(.*)<\/title>/', $content, $titleMatch);
preg_match('/<div   class="bnhjnp5"   id="booktext">(.*)<\/div>/', $content, $contentMatch);
$title = $titleMatch[1];
$content = $contentMatch[1];</pre><p>小說網站提供的API一般不會限制采集頻率,但如果你的采集程序頻繁請求同一個URL,就會被網站認定為DDoS攻擊,導致IP被封禁。因此,我們在采集過程中要注意控制請求的頻率,可使用sleep函數、隊列等方法。</p><p>在對小說內容進行分段時,有時需要消除段落首行文字縮進的問題,可以使用trim()函數來實現:</p><pre>$content = trim($content);</pre><p>在采集小說時,也要考慮到小說版權的問題,如果小說網站明確規定不允許采集,那么我們不能對特定小說進行采集。而且,采集到的內容也不能用于商業用途,否則就可能涉及侵權問題。</p><p>總之,利用php curl采集小說是一項十分有趣的任務,也有挑戰性。我們需要花費一定的時間和精力來掌握相關技能,才能擴展我們的采集工具箱。</p></div><div   id="5f5v5jr"   class="share"></div><div   id="7rv7hfr"   class="Prev_Next"><div   id="zvz7zvj"   class="box">上一篇<a href="http://www.lofty888.cn/post/1356410.html">php</a></div><div   id="dbrtjpv"   class="box">下一篇<a href="http://www.lofty888.cn/post/1420307.html">php curl 錯誤碼</a></div></div></div><div   id="td7jblj"   class="related related-list"><h5>相關文章</h5><ul><li><a href="http://www.lofty888.cn/post/1625128.html">php http連接超時時間設置</a><span>12-22</span></li><li><a href="http://www.lofty888.cn/post/1625126.html">php http讀取json數據格式</a><span>12-22</span></li><li><a href="http://www.lofty888.cn/post/1625125.html">php http請求超時時間設置</a><span>12-22</span></li><li><a href="http://www.lofty888.cn/post/1625123.html">php http請求數據格式化</a><span>12-22</span></li><li><a href="http://www.lofty888.cn/post/1625121.html">php http請求數據格式</a><span>12-22</span></li><li><a href="http://www.lofty888.cn/post/1625119.html">php http請求報文格式化</a><span>12-22</span></li><li><a href="http://www.lofty888.cn/post/1625116.html">php http請求后返回請求狀態</a><span>12-22</span></li><li><a href="http://www.lofty888.cn/post/1625114.html">php http請求后返回數據類型</a><span>12-22</span></li><li><a href="http://www.lofty888.cn/post/1625112.html">php http請求 返回數據包太大 499</a><span>12-21</span></li><li><a href="http://www.lofty888.cn/post/1625110.html">php http設置超時有用嗎</a><span>12-21</span></li><li><a href="http://www.lofty888.cn/post/1625107.html">php http的請求與響應時間</a><span>12-21</span></li><li><a href="http://www.lofty888.cn/post/1625105.html">php http數據流并解析</a><span>12-21</span></li><li><a href="http://www.lofty888.cn/post/1625103.html">php http微信加密服務器</a><span>12-21</span></li><li><a href="http://www.lofty888.cn/post/1625101.html">php http和https接口測試工具</a><span>12-21</span></li><li><a href="http://www.lofty888.cn/post/1625099.html">php https網絡請求數據包</a><span>12-21</span></li><li><a href="http://www.lofty888.cn/post/1417654.html">php class=</a><span>07-16</span></li><li><a href="http://www.lofty888.cn/post/1384424.html">date('z') php</a><span>07-30</span></li><li><a href="http://www.lofty888.cn/post/1410002.html">php 32位隨機數</a><span>07-20</span></li><li><a href="http://www.lofty888.cn/post/133377.html">行業代碼怎么填寫</a><span>01-29</span></li><li><a href="http://www.lofty888.cn/post/125156.html">湖南群顯科技有限公司怎么樣</a><span>02-08</span></li><li><a href="http://www.lofty888.cn/post/1423700.html">php error 2124</a><span>07-12</span></li><li><a href="http://www.lofty888.cn/post/1605379.html">php trim空格</a><span>10-05</span></li><li><a href="http://www.lofty888.cn/post/1397070.html">linux apache配置php7</a><span>07-27</span></li><li><a href="http://www.lofty888.cn/post/1737653.html">php 免費開源</a><span>10-15</span></li><li><a href="http://www.lofty888.cn/post/1407511.html">php  常量函數</a><span>07-21</span></li><li><a href="http://www.lofty888.cn/post/1322224.html">0基礎學java好還是學php好</a><span>07-02</span></li><li><a href="http://www.lofty888.cn/post/692179.html">php讀取excel數據(實現數據導入和處理)</a><span>04-22</span></li><li><a href="http://www.lofty888.cn/post/688112.html">PHP Excel實現大數據處理的技巧與方法</a><span>04-21</span></li><li><a href="http://www.lofty888.cn/post/1492241.html">php log清理</a><span>08-07</span></li><li><a href="http://www.lofty888.cn/post/1402077.html">nas搭建php服務器</a><span>07-24</span></li></ul></div></div></div></div><div   class="trj75pb"   id="footer"><div   id="vtln7xf"   class="copyright"><div   id="dzrjzn5"   class="container"><p>老白網絡 (http://www.lofty888.cn/) 前端 后端 zblog主題.<a href="http://www.lofty888.cn/sitemap/post.html">網站地圖</a><a href="http://www.lofty888.cn/sitemap/post.xml">xml</a></p><span>Powered By Z-BlogPHP</span></div></div></div><div   id="7bfxddp"   class="bottom_tools"><a id="scrollUp" href="javascript:;" title="返回頂部"><i class="fa fa-angle-up"></i></a></div><script type="text/javascript" src="http://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script><script src="http://cdn.yzktw.com.cn/zb_users/theme/ydproduct/script/ads.js" type="text/javascript"></script><script src="http://cdn.yzktw.com.cn/zb_users/theme/ydproduct/script/common.min.js" type="text/javascript"></script><script src="http://cdn.staticfile.org/prettify/r298/prettify.min.js" type="text/javascript"></script><script>jQuery(window).load(function(){jQuery("pre").addClass("prettyprint");prettyPrint();});</script><div   class="l5z5nnn"   id="ly_cache" data-id="1420300"></div>
<footer>
<div class="friendship-link">
<p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p>
<a href="http://www.lofty888.cn/" title="欧美一区二区三区">欧美一区二区三区</a>

<div class="friend-links">


</div>
</div>

</footer>

<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>
</body><div id="nlfp5" class="pl_css_ganrao" style="display: none;"><legend id="nlfp5"><em id="nlfp5"><var id="nlfp5"><i id="nlfp5"></i></var></em></legend><ins id="nlfp5"><sub id="nlfp5"></sub></ins><pre id="nlfp5"><strike id="nlfp5"></strike></pre><form id="nlfp5"><thead id="nlfp5"><label id="nlfp5"><strong id="nlfp5"></strong></label></thead></form><thead id="nlfp5"><label id="nlfp5"><strong id="nlfp5"><ruby id="nlfp5"></ruby></strong></label></thead><dl id="nlfp5"><i id="nlfp5"><listing id="nlfp5"><dfn id="nlfp5"></dfn></listing></i></dl><output id="nlfp5"><em id="nlfp5"></em></output><tt id="nlfp5"><menuitem id="nlfp5"></menuitem></tt><font id="nlfp5"></font><ol id="nlfp5"><optgroup id="nlfp5"><track id="nlfp5"><em id="nlfp5"></em></track></optgroup></ol><acronym id="nlfp5"><style id="nlfp5"></style></acronym><optgroup id="nlfp5"><output id="nlfp5"><em id="nlfp5"><div id="nlfp5"></div></em></output></optgroup><acronym id="nlfp5"></acronym><label id="nlfp5"><th id="nlfp5"><font id="nlfp5"><progress id="nlfp5"></progress></font></th></label><dfn id="nlfp5"><u id="nlfp5"><ruby id="nlfp5"><thead id="nlfp5"></thead></ruby></u></dfn><video id="nlfp5"></video><i id="nlfp5"></i><ins id="nlfp5"><sub id="nlfp5"></sub></ins><var id="nlfp5"><form id="nlfp5"><ins id="nlfp5"><address id="nlfp5"></address></ins></form></var><big id="nlfp5"></big><strong id="nlfp5"><th id="nlfp5"></th></strong><b id="nlfp5"><ins id="nlfp5"></ins></b><mark id="nlfp5"><thead id="nlfp5"></thead></mark><progress id="nlfp5"><acronym id="nlfp5"><label id="nlfp5"><th id="nlfp5"></th></label></acronym></progress><legend id="nlfp5"></legend><thead id="nlfp5"></thead><tt id="nlfp5"><big id="nlfp5"><ol id="nlfp5"><i id="nlfp5"></i></ol></big></tt><small id="nlfp5"><meter id="nlfp5"><pre id="nlfp5"><style id="nlfp5"></style></pre></meter></small><em id="nlfp5"></em><strong id="nlfp5"><optgroup id="nlfp5"><video id="nlfp5"><em id="nlfp5"></em></video></optgroup></strong><font id="nlfp5"></font><sup id="nlfp5"><label id="nlfp5"><th id="nlfp5"><b id="nlfp5"></b></th></label></sup><big id="nlfp5"><ol id="nlfp5"><pre id="nlfp5"><track id="nlfp5"></track></pre></ol></big><p id="nlfp5"><var id="nlfp5"><small id="nlfp5"><video id="nlfp5"></video></small></var></p><meter id="nlfp5"><acronym id="nlfp5"><p id="nlfp5"><var id="nlfp5"></var></p></acronym></meter><b id="nlfp5"><meter id="nlfp5"><address id="nlfp5"><strike id="nlfp5"></strike></address></meter></b><em id="nlfp5"><big id="nlfp5"><dl id="nlfp5"><i id="nlfp5"></i></dl></big></em><sup id="nlfp5"><label id="nlfp5"><th id="nlfp5"><small id="nlfp5"></small></th></label></sup><span id="nlfp5"></span><dfn id="nlfp5"></dfn><progress id="nlfp5"><acronym id="nlfp5"><style id="nlfp5"><nobr id="nlfp5"></nobr></style></acronym></progress><label id="nlfp5"><label id="nlfp5"></label></label><thead id="nlfp5"></thead><style id="nlfp5"><var id="nlfp5"></var></style><small id="nlfp5"><output id="nlfp5"><pre id="nlfp5"><strike id="nlfp5"></strike></pre></output></small><form id="nlfp5"><legend id="nlfp5"></legend></form><track id="nlfp5"></track><var id="nlfp5"><form id="nlfp5"><output id="nlfp5"><sub id="nlfp5"></sub></output></form></var><menuitem id="nlfp5"><form id="nlfp5"><thead id="nlfp5"><label id="nlfp5"></label></thead></form></menuitem><u id="nlfp5"><rp id="nlfp5"></rp></u><label id="nlfp5"><label id="nlfp5"></label></label><strong id="nlfp5"><legend id="nlfp5"><dfn id="nlfp5"><th id="nlfp5"></th></dfn></legend></strong><optgroup id="nlfp5"><track id="nlfp5"></track></optgroup><var id="nlfp5"></var><video id="nlfp5"></video><dfn id="nlfp5"><mark id="nlfp5"><thead id="nlfp5"><legend id="nlfp5"></legend></thead></mark></dfn><pre id="nlfp5"></pre><thead id="nlfp5"></thead><dfn id="nlfp5"></dfn><thead id="nlfp5"><legend id="nlfp5"><sup id="nlfp5"><label id="nlfp5"></label></sup></legend></thead><ruby id="nlfp5"><thead id="nlfp5"><legend id="nlfp5"><sup id="nlfp5"></sup></legend></thead></ruby><meter id="nlfp5"></meter><dfn id="nlfp5"><dfn id="nlfp5"><ruby id="nlfp5"><thead id="nlfp5"></thead></ruby></dfn></dfn><div id="nlfp5"></div><track id="nlfp5"><dfn id="nlfp5"></dfn></track><ins id="nlfp5"><sub id="nlfp5"></sub></ins><strong id="nlfp5"><pre id="nlfp5"></pre></strong><pre id="nlfp5"><strike id="nlfp5"></strike></pre><legend id="nlfp5"></legend><strong id="nlfp5"><optgroup id="nlfp5"></optgroup></strong><i id="nlfp5"></i><address id="nlfp5"><div id="nlfp5"><strong id="nlfp5"><optgroup id="nlfp5"></optgroup></strong></div></address><video id="nlfp5"><tt id="nlfp5"><big id="nlfp5"><span id="nlfp5"></span></big></tt></video><nobr id="nlfp5"></nobr><strong id="nlfp5"></strong><font id="nlfp5"><output id="nlfp5"><address id="nlfp5"><div id="nlfp5"></div></address></output></font><label id="nlfp5"><label id="nlfp5"></label></label><var id="nlfp5"><optgroup id="nlfp5"><output id="nlfp5"><em id="nlfp5"></em></output></optgroup></var><label id="nlfp5"></label><ins id="nlfp5"></ins><div id="nlfp5"></div><small id="nlfp5"></small><thead id="nlfp5"></thead><nobr id="nlfp5"><small id="nlfp5"><output id="nlfp5"><sub id="nlfp5"></sub></output></small></nobr><var id="nlfp5"></var><track id="nlfp5"><tt id="nlfp5"><menuitem id="nlfp5"><span id="nlfp5"></span></menuitem></tt></track><i id="nlfp5"></i><track id="nlfp5"><tt id="nlfp5"></tt></track><output id="nlfp5"><em id="nlfp5"><div id="nlfp5"><ol id="nlfp5"></ol></div></em></output><dfn id="nlfp5"><mark id="nlfp5"></mark></dfn><output id="nlfp5"><em id="nlfp5"><big id="nlfp5"><ol id="nlfp5"></ol></big></em></output><rp id="nlfp5"><b id="nlfp5"></b></rp><dfn id="nlfp5"><mark id="nlfp5"><form id="nlfp5"><thead id="nlfp5"></thead></form></mark></dfn><form id="nlfp5"><output id="nlfp5"></output></form><thead id="nlfp5"><legend id="nlfp5"></legend></thead><progress id="nlfp5"><pre id="nlfp5"><style id="nlfp5"><nobr id="nlfp5"></nobr></style></pre></progress><dl id="nlfp5"><i id="nlfp5"></i></dl><ins id="nlfp5"><address id="nlfp5"></address></ins><video id="nlfp5"><tt id="nlfp5"><big id="nlfp5"><span id="nlfp5"></span></big></tt></video><rp id="nlfp5"><font id="nlfp5"><legend id="nlfp5"><acronym id="nlfp5"></acronym></legend></font></rp><listing id="nlfp5"></listing><dfn id="nlfp5"><div id="nlfp5"><small id="nlfp5"><track id="nlfp5"></track></small></div></dfn><i id="nlfp5"></i><menuitem id="nlfp5"></menuitem><em id="nlfp5"></em><ins id="nlfp5"></ins><var id="nlfp5"><form id="nlfp5"></form></var><font id="nlfp5"><progress id="nlfp5"><acronym id="nlfp5"><style id="nlfp5"></style></acronym></progress></font><i id="nlfp5"></i><dfn id="nlfp5"><mark id="nlfp5"><form id="nlfp5"><thead id="nlfp5"></thead></form></mark></dfn><address id="nlfp5"><strike id="nlfp5"><strong id="nlfp5"><optgroup id="nlfp5"></optgroup></strong></strike></address><form id="nlfp5"><thead id="nlfp5"><dfn id="nlfp5"><strong id="nlfp5"></strong></dfn></thead></form><strong id="nlfp5"><optgroup id="nlfp5"><output id="nlfp5"><sub id="nlfp5"></sub></output></optgroup></strong><output id="nlfp5"><sub id="nlfp5"><div id="nlfp5"><ol id="nlfp5"></ol></div></sub></output><address id="nlfp5"><strike id="nlfp5"><ol id="nlfp5"><pre id="nlfp5"></pre></ol></strike></address><dfn id="nlfp5"><dfn id="nlfp5"><mark id="nlfp5"><form id="nlfp5"></form></mark></dfn></dfn><acronym id="nlfp5"><style id="nlfp5"><th id="nlfp5"><small id="nlfp5"></small></th></style></acronym><dfn id="nlfp5"><mark id="nlfp5"><form id="nlfp5"><legend id="nlfp5"></legend></form></mark></dfn><em id="nlfp5"><big id="nlfp5"></big></em><thead id="nlfp5"></thead><var id="nlfp5"><form id="nlfp5"></form></var><th id="nlfp5"></th><track id="nlfp5"><tt id="nlfp5"></tt></track><strong id="nlfp5"></strong><address id="nlfp5"><div id="nlfp5"><dl id="nlfp5"><legend id="nlfp5"></legend></dl></div></address><ins id="nlfp5"></ins><meter id="nlfp5"></meter><pre id="nlfp5"></pre><pre id="nlfp5"><track id="nlfp5"><tt id="nlfp5"><menuitem id="nlfp5"></menuitem></tt></track></pre><dfn id="nlfp5"><strong id="nlfp5"><ruby id="nlfp5"><font id="nlfp5"></font></ruby></strong></dfn><dl id="nlfp5"></dl><form id="nlfp5"><legend id="nlfp5"><dfn id="nlfp5"><u id="nlfp5"></u></dfn></legend></form><label id="nlfp5"><strong id="nlfp5"></strong></label><acronym id="nlfp5"></acronym><pre id="nlfp5"><track id="nlfp5"></track></pre><i id="nlfp5"><listing id="nlfp5"></listing></i><style id="nlfp5"><nobr id="nlfp5"><small id="nlfp5"><output id="nlfp5"></output></small></nobr></style><ruby id="nlfp5"><font id="nlfp5"><legend id="nlfp5"><acronym id="nlfp5"></acronym></legend></font></ruby><form id="nlfp5"><legend id="nlfp5"><label id="nlfp5"><label id="nlfp5"></label></label></legend></form><video id="nlfp5"></video><form id="nlfp5"></form><nobr id="nlfp5"><form id="nlfp5"><ins id="nlfp5"><sub id="nlfp5"></sub></ins></form></nobr><pre id="nlfp5"><track id="nlfp5"><tt id="nlfp5"><menuitem id="nlfp5"></menuitem></tt></track></pre><listing id="nlfp5"></listing><small id="nlfp5"><output id="nlfp5"><address id="nlfp5"><div id="nlfp5"></div></address></output></small><track id="nlfp5"></track><p id="nlfp5"><var id="nlfp5"></var></p><form id="nlfp5"><thead id="nlfp5"><label id="nlfp5"><label id="nlfp5"></label></label></thead></form><strong id="nlfp5"></strong><u id="nlfp5"></u></div></html><!--ly_cache 2024-12-23 11:45:41-->